From 4d61a80a7cb652ed264c1d47a3c1ff3eac7003b7 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Wed, 10 Dec 2025 13:12:47 +0100 Subject: [PATCH] better workspace indicator styling --- CMakeLists.txt | 30 +++++++++++++++++++++++++++++- resources/bar.css | 7 +++---- src/services/hyprland.cpp | 22 ---------------------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d0cd17..8eac247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 4.2.0) project(bar) -set(CMAKE_CXX_STANDARD 26) +set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -9,6 +9,18 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") find_package(PkgConfig REQUIRED) +# Some CMake versions may enable C++ modules and add compiler flags +# like `-fmodules-ts`. Older or certain `clang`/`clangd` builds may +# not accept this flag and will report "Unknown argument: '-fmodules-ts'". +# Strip that flag when using Clang to avoid diagnostics from clang/clangd. +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") + string(REPLACE "-fmodules-ts" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "-fmodules-ts" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "-fmodules-ts" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "-fmodules-ts" "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") + string(REPLACE "-fmodules-ts" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") +endif() + pkg_check_modules(GTKMM REQUIRED gtkmm-4.0) pkg_check_modules(LAYERSHELL REQUIRED gtk4-layer-shell-0) @@ -34,3 +46,19 @@ include_directories(bar_lib PRIVATE add_executable(bar main.cpp) target_link_libraries(bar bar_lib ${GTKMM_LIBRARIES} ${LAYERSHELL_LIBRARIES}) + +# Copy `resources/bar.css` into the build directory when it changes +set(RES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/bar.css") +set(RES_DST "${CMAKE_CURRENT_BINARY_DIR}/resources/bar.css") + +add_custom_command( + OUTPUT ${RES_DST} + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/resources" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RES_SRC}" "${RES_DST}" + DEPENDS "${RES_SRC}" + COMMENT "Copy resources/bar.css to build directory" + VERBATIM +) + +add_custom_target(copy_resources ALL DEPENDS ${RES_DST}) +add_dependencies(bar copy_resources) diff --git a/resources/bar.css b/resources/bar.css index 50f1b69..8f0359f 100644 --- a/resources/bar.css +++ b/resources/bar.css @@ -18,7 +18,6 @@ window { } .workspace-pill { - background-color: rgba(255, 255, 255, 0.12); padding: 2px 5px; margin-right: 6px; border-radius: 5px; @@ -29,11 +28,11 @@ window { } .workspace-pill-focused { - background-color: rgba(255, 255, 255, 0.18); + background-color: rgba(104, 104, 104, 0.3); } .workspace-pill-active { - background-color: rgba(255, 255, 255, 0.25); + background-color: rgba(168, 168, 168, 0.4); } .workspace-pill-urgent { @@ -43,7 +42,7 @@ window { /* Hover effect: slightly brighten background and show pointer */ .workspace-pill:hover { - background-color: rgba(255, 255, 255, 0.20); + background-color: rgba(255, 255, 255, 0.3); } .tray-icon { diff --git a/src/services/hyprland.cpp b/src/services/hyprland.cpp index 9c78b4e..ca8e1da 100644 --- a/src/services/hyprland.cpp +++ b/src/services/hyprland.cpp @@ -348,30 +348,8 @@ void HyprlandService::switchToWorkspace(int monitorId, int slot) auto wsIt = monitor.workspaceStates.find(slot); std::string cmd; - if (wsIt != monitor.workspaceStates.end() && wsIt->second.hyprId >= 0) - { // Use the Hyprland workspace id if available cmd = "hyprctl dispatch workspace " + std::to_string(wsIt->second.hyprId); - } - else - { - // Fallback: ask Hyprland to switch/create a workspace on the monitor - // by using the slot number and the monitor name. Syntax: ":" - // Example: hyprctl dispatch workspace 2:DP-1 - // This may vary by Hyprland version; if it doesn't work on your system - // adjust the command accordingly. - std::string monName = monitor.name; - if (monName.empty()) - { - // As a last resort, just try the slot number globally - cmd = "hyprctl dispatch workspace " + std::to_string(slot); - } - else - { - // Quote monitor name in case it contains spaces - cmd = "hyprctl dispatch workspace " + std::to_string(slot) + ":\"" + monName + "\""; - } - } try {