refactor notifications

This commit is contained in:
2026-02-01 16:10:42 +01:00
parent 17aef717b7
commit 178a4451d4
18 changed files with 449 additions and 236 deletions

View File

@@ -28,7 +28,9 @@ target_sources(bar_lib
src/widgets/clock.cpp
src/widgets/date.cpp
src/widgets/notification.cpp
src/widgets/notification/baseNotification.cpp
src/widgets/notification/notification.cpp
src/widgets/notification/spotifyNotification.cpp
src/widgets/volumeWidget.cpp
src/widgets/webWidget.cpp
@@ -54,28 +56,35 @@ add_executable(bar main.cpp)
target_link_libraries(bar bar_lib ${GTKMM_LIBRARIES} ${LAYERSHELL_LIBRARIES} ${WEBKIT_LIBRARIES} ${CURL_LIBRARIES} nlohmann_json::nlohmann_json)
# 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")
set(USER_CONFIG_CSS "$ENV{HOME}/.config/bar/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
# Copy all CSS files in resources/ into build and user config directories
file(GLOB RES_CSS_FILES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/resources/*.css"
)
set(RES_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/resources")
set(RES_USER_DIR "$ENV{HOME}/.config/bar")
add_custom_command(
OUTPUT ${USER_CONFIG_CSS}
COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{HOME}/.config/bar"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RES_SRC}" "${USER_CONFIG_CSS}"
DEPENDS "${RES_SRC}"
COMMENT "Copy resources/bar.css to ~/.config/bar/bar.css"
VERBATIM
)
set(RES_DST_FILES "")
set(USER_DST_FILES "")
add_custom_target(copy_resources ALL DEPENDS ${RES_DST} ${USER_CONFIG_CSS})
foreach(RES_FILE IN LISTS RES_CSS_FILES)
get_filename_component(RES_NAME "${RES_FILE}" NAME)
set(RES_DST "${RES_BUILD_DIR}/${RES_NAME}")
set(USER_DST "${RES_USER_DIR}/${RES_NAME}")
list(APPEND RES_DST_FILES "${RES_DST}")
list(APPEND USER_DST_FILES "${USER_DST}")
add_custom_command(
OUTPUT "${RES_DST}" "${USER_DST}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${RES_BUILD_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${RES_USER_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RES_FILE}" "${RES_DST}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RES_FILE}" "${USER_DST}"
DEPENDS "${RES_FILE}"
COMMENT "Copy ${RES_NAME} to build and config directories"
VERBATIM
)
endforeach()
add_custom_target(copy_resources ALL DEPENDS ${RES_DST_FILES} ${USER_DST_FILES})
add_dependencies(bar copy_resources)