From 1ce6610453bd63f5c98bcaf293d1216d5409dd58 Mon Sep 17 00:00:00 2001 From: alba4k Date: Thu, 11 Apr 2024 19:51:22 +0200 Subject: [PATCH 1/2] Added systemd service --- CMakeLists.txt | 2 ++ README.md | 16 ++++++++++++++-- systemd/hypridle.service.in | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 systemd/hypridle.service.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 85d27fc..e6f3565 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories( set(CMAKE_CXX_STANDARD 23) add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing) +configure_file(systemd/hypridle.service.in systemd/hypridle.service @ONLY) # dependencies message(STATUS "Checking deps...") @@ -73,3 +74,4 @@ protocol("staging/ext-idle-notify/ext-idle-notify-v1.xml" "ext-idle-notify-v1" f # Installation install(TARGETS hypridle) +install(FILES ${CMAKE_BINARY_DIR}/systemd/hypridle.service DESTINATION "lib/systemd/user") diff --git a/README.md b/README.md index c871250..41db3b3 100644 --- a/README.md +++ b/README.md @@ -38,17 +38,29 @@ will make those events ignored. ## Building & Installation -Building: +### Building: ```sh cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build cmake --build ./build --config Release --target hypridle -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` ``` -Installation: +### Installation: ```sh sudo cmake --install build ``` +### Usage: + +Hypridle should ideally be launched after logging in. This can be done by your compositor or by systemd. +For example, for Hyprland, use the following in your `hyprland.conf`. +```hyprlang +exec-once = hypridle +``` +If, instead, you want to have systemd do this for you, you'll just need to enable the service using +```sh +systemctl --user enable --now hypridle.service +``` + ## Flags ``` diff --git a/systemd/hypridle.service.in b/systemd/hypridle.service.in new file mode 100644 index 0000000..fa2cccf --- /dev/null +++ b/systemd/hypridle.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=Hyprland's idle daemon +Documentation=https://wiki.hyprland.org/Hypr-Ecosystem/hypridle +PartOf=graphical-session.target +After=graphical-session.target +ConditionEnvironment=WAYLAND_DISPLAY + +[Service] +Type=simple +ExecStart=@BINDIR@/hypridle +Restart=on-failure + +[Install] +WantedBy=graphical-session.target From 6a5aaa1f2d187d11fc3c74200c8b86ddeba6135f Mon Sep 17 00:00:00 2001 From: alba4k Date: Fri, 12 Apr 2024 13:54:03 +0200 Subject: [PATCH 2/2] fixed the usage of cmake variables --- CMakeLists.txt | 2 +- systemd/hypridle.service.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6f3565..2ce4963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,4 +74,4 @@ protocol("staging/ext-idle-notify/ext-idle-notify-v1.xml" "ext-idle-notify-v1" f # Installation install(TARGETS hypridle) -install(FILES ${CMAKE_BINARY_DIR}/systemd/hypridle.service DESTINATION "lib/systemd/user") +install(FILES ${CMAKE_BINARY_DIR}/systemd/hypridle.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user) diff --git a/systemd/hypridle.service.in b/systemd/hypridle.service.in index fa2cccf..2571d20 100644 --- a/systemd/hypridle.service.in +++ b/systemd/hypridle.service.in @@ -7,7 +7,7 @@ ConditionEnvironment=WAYLAND_DISPLAY [Service] Type=simple -ExecStart=@BINDIR@/hypridle +ExecStart=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/hypridle Restart=on-failure [Install]