Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package hypridle for openSUSE:Factory checked in at 2024-12-20 23:11:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hypridle (Old) and /work/SRC/openSUSE:Factory/.hypridle.new.1881 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hypridle" Fri Dec 20 23:11:38 2024 rev:3 rq:1232852 version:0.1.5 Changes: -------- --- /work/SRC/openSUSE:Factory/hypridle/hypridle.changes 2024-04-23 18:57:23.201306808 +0200 +++ /work/SRC/openSUSE:Factory/.hypridle.new.1881/hypridle.changes 2024-12-20 23:12:34.481307030 +0100 @@ -1,0 +2,37 @@ +Tue Dec 10 21:13:41 UTC 2024 - [email protected] + +- Update to version 0.1.5: + * Tiny update to fix dbus inhibitor locks not being decremented + properly. + * Core: handleDbusScreensaver must return uint32, + (gh#hyprwm/hypridle#98). +- Changes from version 0.1.4: + * Sdbus-cpp -> moved to >=2.0.0 + * Core: move to sdbus-cpp2, (gh#hyprwm/hypridle#96). +- Changes from version 0.1.3: + * Add support for systemd-inhibit idle block inhibits, + (gh#hyprwm/hypridle#57). + * Use separate ignore_systemd_inhibit config param for systemd. + Register ScreenSaver object under multiple paths, + (gh#hyprwm/hypridle#59). + * Fixed getconf command in build instructions, + (gh#hyprwm/hypridle#60). + * Reset timers after inhibitor has been taken off if idled, + (gh#hyprwm/hypridle#72). + * Config: use hyprutils helper, (gh#hyprwm/hypridle#77). + * Fix running without logind, (gh#hyprwm/hypridle#76). + * Typo fix hyprlock->hypridle, (gh#hyprwm/hypridle#82). + * Include Log.hpp in main, (gh#hyprwm/hypridle#87). + * Flush cout buffer automatically, (gh#hyprwm/hypridle#88). + * Nix: add wayland-scanner native build input, + (gh#hyprwm/hypridle#89). + * Do not crash if the last CLI parameter was -c, + (gh#hyprwm/hypridle#92). + * Core: release inhibit cookies on app disconnect from dbus, + (gh#hyprwm/hypridle#93). +- Add build requires on pkgconfig(hyprutils). +- Add build requires on Hyprland for directory ownership. +- Add default hypridle.conf now installed from the source, but + retain example. + +------------------------------------------------------------------- Old: ---- hypridle-0.1.2.obscpio New: ---- hypridle-0.1.5.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hypridle.spec ++++++ --- /var/tmp/diff_new_pack.CJUA2w/_old 2024-12-20 23:12:35.033329794 +0100 +++ /var/tmp/diff_new_pack.CJUA2w/_new 2024-12-20 23:12:35.033329794 +0100 @@ -17,7 +17,7 @@ Name: hypridle -Version: 0.1.2 +Version: 0.1.5 Release: 0 Summary: Hyprland's idle daemon License: BSD-3-Clause @@ -26,8 +26,11 @@ Source1: hypridle.conf BuildRequires: cmake BuildRequires: gcc-c++ +## Added for directory ownership +BuildRequires: hyprland BuildRequires: pkg-config BuildRequires: pkgconfig(hyprlang) >= 0.4.2 +BuildRequires: pkgconfig(hyprutils) BuildRequires: pkgconfig(sdbus-c++) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(wayland-protocols) @@ -54,5 +57,6 @@ %license LICENSE %doc README.md hypridle.conf.example %{_bindir}/hypridle +%{_datadir}/hypr/hypridle.conf %{_userunitdir}/hypridle.service ++++++ hypridle-0.1.2.obscpio -> hypridle-0.1.5.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/CMakeLists.txt new/hypridle-0.1.5/CMakeLists.txt --- old/hypridle-0.1.2/CMakeLists.txt 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/CMakeLists.txt 2024-11-02 16:29:47.000000000 +0100 @@ -1,31 +1,31 @@ cmake_minimum_required(VERSION 3.19) -set(VERSION 0.1.2) +file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW) +string(STRIP ${VER_RAW} VERSION) -project(hypridle - DESCRIPTION "An idle management daemon for Hyprland" - VERSION ${VERSION} -) +project( + hypridle + DESCRIPTION "An idle management daemon for Hyprland" + VERSION ${VERSION}) set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) - message(STATUS "Configuring hypridle in Debug with CMake") - add_compile_definitions(HYPRLAND_DEBUG) + message(STATUS "Configuring hypridle in Debug with CMake") + add_compile_definitions(HYPRLAND_DEBUG) else() - add_compile_options(-O3) - message(STATUS "Configuring hypridle in Release with CMake") + add_compile_options(-O3) + message(STATUS "Configuring hypridle in Release with CMake") endif() -include_directories( - . - "protocols/" -) +include_directories(. "protocols/") + +include(GNUInstallDirs) # configure set(CMAKE_CXX_STANDARD 23) add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value - -Wno-missing-field-initializers -Wno-narrowing) + -Wno-missing-field-initializers -Wno-narrowing) configure_file(systemd/hypridle.service.in systemd/hypridle.service @ONLY) # dependencies @@ -33,7 +33,15 @@ find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols hyprlang>=0.4.0 sdbus-c++) +pkg_check_modules( + deps + REQUIRED + IMPORTED_TARGET + wayland-client + wayland-protocols + hyprlang>=0.4.0 + hyprutils>=0.2.0 + sdbus-c++>=0.2.0) file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") add_executable(hypridle ${SRCFILES}) @@ -43,35 +51,49 @@ find_program(WaylandScanner NAMES wayland-scanner) message(STATUS "Found WaylandScanner at ${WaylandScanner}") execute_process( - COMMAND pkg-config --variable=pkgdatadir wayland-protocols - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) + COMMAND pkg-config --variable=pkgdatadir wayland-protocols + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}") function(protocol protoPath protoName external) - if (external) - execute_process( - COMMAND ${WaylandScanner} client-header ${protoPath} protocols/${protoName}-protocol.h - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - execute_process( - COMMAND ${WaylandScanner} private-code ${protoPath} protocols/${protoName}-protocol.c - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - target_sources(hypridle PRIVATE protocols/${protoName}-protocol.c) - else() - execute_process( - COMMAND ${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.h - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - execute_process( - COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.c - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - target_sources(hypridle PRIVATE protocols/${protoName}-protocol.c) - endif() + if(external) + execute_process( + COMMAND ${WaylandScanner} client-header ${protoPath} + protocols/${protoName}-protocol.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + execute_process( + COMMAND ${WaylandScanner} private-code ${protoPath} + protocols/${protoName}-protocol.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + target_sources(hypridle PRIVATE protocols/${protoName}-protocol.c) + else() + execute_process( + COMMAND + ${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} + protocols/${protoName}-protocol.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + execute_process( + COMMAND + ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} + protocols/${protoName}-protocol.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + target_sources(hypridle PRIVATE protocols/${protoName}-protocol.c) + endif() endfunction() -make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so the dir won't be there -protocol("staging/ext-idle-notify/ext-idle-notify-v1.xml" "ext-idle-notify-v1" false) +make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so + # the dir won't be there +protocol("staging/ext-idle-notify/ext-idle-notify-v1.xml" "ext-idle-notify-v1" + false) # 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 "lib/systemd/user") + +install( + FILES ${CMAKE_SOURCE_DIR}/assets/example.conf + DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/hypr + RENAME hypridle.conf) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/README.md new/hypridle-0.1.5/README.md --- old/hypridle-0.1.2/README.md 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/README.md 2024-11-02 16:29:47.000000000 +0100 @@ -18,6 +18,7 @@ before_sleep_cmd = notify-send "Zzz" # command ran before sleep after_sleep_cmd = notify-send "Awake!" # command ran after sleep ignore_dbus_inhibit = false # whether to ignore dbus-sent idle-inhibit requests (used by e.g. firefox or steam) + ignore_systemd_inhibit = false # whether to ignore systemd-inhibit --what=idle inhibitors } listener { @@ -41,7 +42,7 @@ ### 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` +cmake --build ./build --config Release --target hypridle -j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF` ``` ### Installation: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/VERSION new/hypridle-0.1.5/VERSION --- old/hypridle-0.1.2/VERSION 1970-01-01 01:00:00.000000000 +0100 +++ new/hypridle-0.1.5/VERSION 2024-11-02 16:29:47.000000000 +0100 @@ -0,0 +1 @@ +0.1.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/assets/example.conf new/hypridle-0.1.5/assets/example.conf --- old/hypridle-0.1.2/assets/example.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/hypridle-0.1.5/assets/example.conf 2024-11-02 16:29:47.000000000 +0100 @@ -0,0 +1,17 @@ +# sample hypridle.conf +# for more configuration options, refer https://wiki.hyprland.org/Hypr-Ecosystem/hypridle + +general { + lock_cmd = notify-send "lock!" # dbus/sysd lock command (loginctl lock-session) + unlock_cmd = notify-send "unlock!" # same as above, but unlock + before_sleep_cmd = notify-send "Zzz" # command ran before sleep + after_sleep_cmd = notify-send "Awake!" # command ran after sleep + ignore_dbus_inhibit = false # whether to ignore dbus-sent idle-inhibit requests (used by e.g. firefox or steam) + ignore_systemd_inhibit = false # whether to ignore systemd-inhibit --what=idle inhibitors +} + +listener { + timeout = 300 # in seconds + on-timeout = notify-send "You are idle!" # command to run when timeout has passed + on-resume = notify-send "Welcome back!" # command to run when activity is detected after timeout has fired. +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/flake.lock new/hypridle-0.1.5/flake.lock --- old/hypridle-0.1.2/flake.lock 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/flake.lock 2024-11-02 16:29:47.000000000 +0100 @@ -2,17 +2,22 @@ "nodes": { "hyprlang": { "inputs": { + "hyprutils": [ + "hyprutils" + ], "nixpkgs": [ "nixpkgs" ], - "systems": "systems" + "systems": [ + "systems" + ] }, "locked": { - "lastModified": 1713121246, - "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", + "lastModified": 1721324361, + "narHash": "sha256-BiJKO0IIdnSwHQBSrEJlKlFr753urkLE48wtt0UhNG4=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", + "rev": "adbefbf49664a6c2c8bf36b6487fd31e3eb68086", "type": "github" }, "original": { @@ -21,13 +26,36 @@ "type": "github" } }, + "hyprutils": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1721324102, + "narHash": "sha256-WAZ0X6yJW1hFG6otkHBfyJDKRpNP5stsRqdEuHrFRpk=", + "owner": "hyprwm", + "repo": "hyprutils", + "rev": "962582a090bc233c4de9d9897f46794280288989", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprutils", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1712963716, - "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", + "lastModified": 1721138476, + "narHash": "sha256-+W5eZOhhemLQxelojLxETfbFbc19NWawsXBlapYpqIA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", + "rev": "ad0b5eed1b6031efaed382844806550c3dcb4206", "type": "github" }, "original": { @@ -40,29 +68,15 @@ "root": { "inputs": { "hyprlang": "hyprlang", + "hyprutils": "hyprutils", "nixpkgs": "nixpkgs", - "systems": "systems_2" + "systems": "systems" } }, "systems": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", "repo": "default-linux", "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/flake.nix new/hypridle-0.1.5/flake.nix --- old/hypridle-0.1.2/flake.nix 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/flake.nix 2024-11-02 16:29:47.000000000 +0100 @@ -8,6 +8,14 @@ hyprlang = { url = "github:hyprwm/hyprlang"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.systems.follows = "systems"; + inputs.hyprutils.follows = "hyprutils"; + }; + + hyprutils = { + url = "github:hyprwm/hyprutils"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.systems.follows = "systems"; }; }; @@ -35,7 +43,7 @@ homeManagerModules = { default = self.homeManagerModules.hypridle; - hypridle = import ./nix/hm-module.nix self; + hypridle = builtins.throw "hypridle: the flake HM module has been removed. Use the module from Home Manager upstream."; }; checks = eachSystem (system: self.packages.${system}); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/nix/default.nix new/hypridle-0.1.5/nix/default.nix --- old/hypridle-0.1.2/nix/default.nix 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/nix/default.nix 2024-11-02 16:29:47.000000000 +0100 @@ -4,10 +4,12 @@ cmake, pkg-config, hyprlang, + hyprutils, sdbus-cpp, systemd, wayland, wayland-protocols, + wayland-scanner, version ? "git", }: stdenv.mkDerivation { @@ -18,10 +20,12 @@ nativeBuildInputs = [ cmake pkg-config + wayland-scanner ]; buildInputs = [ hyprlang + hyprutils sdbus-cpp systemd wayland diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/nix/hm-module.nix new/hypridle-0.1.5/nix/hm-module.nix --- old/hypridle-0.1.2/nix/hm-module.nix 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/nix/hm-module.nix 1970-01-01 01:00:00.000000000 +0100 @@ -1,120 +0,0 @@ -self: { - config, - pkgs, - lib, - ... -}: let - inherit (builtins) toString; - inherit (lib.types) bool int listOf package str submodule; - inherit (lib.modules) mkIf; - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.meta) getExe; - - cfg = config.services.hypridle; -in { - options.services.hypridle = { - enable = mkEnableOption "Hypridle, Hyprland's idle daemon"; - - package = mkOption { - description = "The hypridle package"; - type = package; - default = self.packages.${pkgs.stdenv.hostPlatform.system}.hypridle; - }; - - listeners = mkOption { - description = "The hypridle listeners"; - type = listOf (submodule { - options = { - timeout = mkOption { - description = "The timeout for the hypridle service, in seconds"; - type = int; - default = 500; - }; - - onTimeout = mkOption { - description = "The command to run when the timeout is reached"; - type = str; - default = "echo 'timeout reached'"; - }; - - onResume = mkOption { - description = "The command to run when the service resumes"; - type = str; - default = "echo 'service resumed'"; - }; - }; - }); - default = []; - }; - - lockCmd = mkOption { - description = "The command to run when the service locks"; - type = str; - default = "echo 'lock!'"; - }; - - unlockCmd = mkOption { - description = "The command to run when the service unlocks"; - type = str; - default = "echo 'unlock!'"; - }; - - afterSleepCmd = mkOption { - description = "The command to run after the service sleeps"; - type = str; - default = "echo 'Awake...'"; - }; - - beforeSleepCmd = mkOption { - description = "The command to run before the service sleeps"; - type = str; - default = "echo 'Zzz...'"; - }; - - ignoreDbusInhibit = mkOption { - description = "Whether to ignore dbus-sent idle-inhibit requests (used by e.g. firefox or steam)"; - type = bool; - default = false; - }; - }; - - config = mkIf cfg.enable { - xdg.configFile."hypr/hypridle.conf".text = '' - general { - lock_cmd = ${cfg.lockCmd} - unlock_cmd = ${cfg.unlockCmd} - before_sleep_cmd = ${cfg.beforeSleepCmd} - after_sleep_cmd = ${cfg.afterSleepCmd} - ignore_dbus_inhibit = ${ - if cfg.ignoreDbusInhibit - then "true" - else "false" - } - } - - ${builtins.concatStringsSep "\n" (map (listener: '' - listener { - timeout = ${toString listener.timeout} - on-timeout = ${listener.onTimeout} - on-resume = ${listener.onResume} - } - '') - cfg.listeners)} - ''; - - systemd.user.services.hypridle = { - Unit = { - Description = "Hypridle"; - After = ["graphical-session.target"]; - }; - - Service = { - ExecStart = "${getExe cfg.package}"; - Restart = "always"; - RestartSec = "10"; - }; - - Install.WantedBy = [ "default.target" ]; - }; - }; -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/nix/overlays.nix new/hypridle-0.1.5/nix/overlays.nix --- old/hypridle-0.1.2/nix/overlays.nix 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/nix/overlays.nix 2024-11-02 16:29:47.000000000 +0100 @@ -7,17 +7,34 @@ (builtins.substring 4 2 longDate) (builtins.substring 6 2 longDate) ]); + + version = lib.removeSuffix "\n" (builtins.readFile ../VERSION); in { default = inputs.self.overlays.hypridle; hypridle = lib.composeManyExtensions [ inputs.hyprlang.overlays.default + inputs.hyprutils.overlays.default + inputs.self.overlays.sdbuscpp (final: prev: { hypridle = prev.callPackage ./default.nix { stdenv = prev.gcc13Stdenv; - version = "0.pre" + "+date=" + (mkDate (inputs.self.lastModifiedDate or "19700101")) + "_" + (inputs.self.shortRev or "dirty"); + version = version + "+date=" + (mkDate (inputs.self.lastModifiedDate or "19700101")) + "_" + (inputs.self.shortRev or "dirty"); inherit (final) hyprlang; }; }) ]; + + sdbuscpp = final: prev: { + sdbus-cpp = prev.sdbus-cpp.overrideAttrs (self: super: { + version = "2.0.0"; + + src = final.fetchFromGitHub { + owner = "Kistler-group"; + repo = "sdbus-cpp"; + rev = "refs/tags/v${self.version}"; + hash = "sha256-W8V5FRhV3jtERMFrZ4gf30OpIQLYoj2yYGpnYOmH2+g="; + }; + }); + }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/src/config/ConfigManager.cpp new/hypridle-0.1.5/src/config/ConfigManager.cpp --- old/hypridle-0.1.2/src/config/ConfigManager.cpp 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/src/config/ConfigManager.cpp 2024-11-02 16:29:47.000000000 +0100 @@ -1,20 +1,17 @@ #include "ConfigManager.hpp" +#include <hyprutils/path/Path.hpp> #include <filesystem> -static std::string getConfigDir() { - static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); - - if (xdgConfigHome && std::filesystem::path(xdgConfigHome).is_absolute()) - return xdgConfigHome; - - return getenv("HOME") + std::string("/.config"); -} - static std::string getMainConfigPath() { - return getConfigDir() + "/hypr/hypridle.conf"; + static const auto paths = Hyprutils::Path::findConfig("hypridle"); + if (paths.first.has_value()) + return paths.first.value(); + else + throw std::runtime_error("Could not find config in HOME, XDG_CONFIG_HOME, XDG_CONFIG_DIRS or /etc/hypr."); } -CConfigManager::CConfigManager(std::string configPath) : m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) { +CConfigManager::CConfigManager(std::string configPath) : + m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) { ; } @@ -29,6 +26,7 @@ m_config.addConfigValue("general:before_sleep_cmd", Hyprlang::STRING{""}); m_config.addConfigValue("general:after_sleep_cmd", Hyprlang::STRING{""}); m_config.addConfigValue("general:ignore_dbus_inhibit", Hyprlang::INT{0}); + m_config.addConfigValue("general:ignore_systemd_inhibit", Hyprlang::INT{0}); m_config.commence(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/src/core/Hypridle.cpp new/hypridle-0.1.5/src/core/Hypridle.cpp --- old/hypridle-0.1.2/src/core/Hypridle.cpp 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/src/core/Hypridle.cpp 2024-11-02 16:29:47.000000000 +0100 @@ -88,6 +88,8 @@ void CHypridle::enterEventLoop() { + nfds_t pollfdsCount = m_sDBUSState.screenSaverServiceConnection ? 3 : 2; + pollfd pollfds[] = { { .fd = m_sDBUSState.connection->getEventLoopPollData().fd, @@ -103,16 +105,16 @@ }, }; - std::thread pollThr([this, &pollfds]() { + std::thread pollThr([this, &pollfds, &pollfdsCount]() { while (1) { - int ret = poll(pollfds, m_sDBUSState.screenSaverServiceConnection ? 3 : 2, 5000 /* 5 seconds, reasonable. It's because we might need to terminate */); + int ret = poll(pollfds, pollfdsCount, 5000 /* 5 seconds, reasonable. It's because we might need to terminate */); if (ret < 0) { Debug::log(CRIT, "[core] Polling fds failed with {}", errno); m_bTerminate = true; exit(1); } - for (size_t i = 0; i < 3; ++i) { + for (size_t i = 0; i < pollfdsCount; ++i) { if (pollfds[i].revents & POLLHUP) { Debug::log(CRIT, "[core] Disconnected from pollfd id {}", i); m_bTerminate = true; @@ -151,7 +153,7 @@ if (pollfds[0].revents & POLLIN /* dbus */) { Debug::log(TRACE, "got dbus event"); - while (m_sDBUSState.connection->processPendingRequest()) { + while (m_sDBUSState.connection->processPendingEvent()) { ; } } @@ -167,9 +169,9 @@ } } - if (pollfds[2].revents & POLLIN /* dbus2 */) { + if (pollfdsCount > 2 && pollfds[2].revents & POLLIN /* dbus2 */) { Debug::log(TRACE, "got dbus event"); - while (m_sDBUSState.screenSaverServiceConnection->processPendingRequest()) { + while (m_sDBUSState.screenSaverServiceConnection->processPendingEvent()) { ; } } @@ -295,21 +297,28 @@ void CHypridle::onInhibit(bool lock) { m_iInhibitLocks += lock ? 1 : -1; + if (m_iInhibitLocks < 0) { - // what would be safer appending one or setting to 0? - // what if would be equal -2? - // you have been warned. + Debug::log(WARN, "BUG THIS: inhibit locks < 0: {}", m_iInhibitLocks); m_iInhibitLocks = 0; - Debug::log(WARN, "BUG THIS: inhibit locks < 0. Brought back to 0."); - } else if (m_iInhibitLocks > 0) { - Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks); - } else { - Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks); - if (isIdled && lock) { - Debug::log(LOG, "Running from onInhibit() isIdled = true {}", g_pConfigManager->getOnTimeoutCommand()); - spawn(g_pConfigManager->getOnTimeoutCommand()); + } + + if (m_iInhibitLocks == 0 && isIdled) { + const auto RULES = g_pConfigManager->getRules(); + + for (size_t i = 0; i < RULES.size(); ++i) { + auto& l = m_sWaylandIdleState.listeners[i]; + const auto& r = RULES[i]; + + ext_idle_notification_v1_destroy(l.notification); + + l.notification = ext_idle_notifier_v1_get_idle_notification(m_sWaylandIdleState.notifier, r.timeout * 1000 /* ms */, m_sWaylandState.seat); + + ext_idle_notification_v1_add_listener(l.notification, &idleListener, &l); } } + + Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks); } CHypridle::SDbusInhibitCookie CHypridle::getDbusInhibitCookie(uint32_t cookie) { @@ -325,24 +334,36 @@ m_sDBUSState.inhibitCookies.push_back(cookie); } -void CHypridle::unregisterDbusInhibitCookie(const CHypridle::SDbusInhibitCookie& cookie) { +bool CHypridle::unregisterDbusInhibitCookie(const CHypridle::SDbusInhibitCookie& cookie) { const auto IT = std::find_if(m_sDBUSState.inhibitCookies.begin(), m_sDBUSState.inhibitCookies.end(), [&cookie](const CHypridle::SDbusInhibitCookie& item) { return item.cookie == cookie.cookie; }); if (IT == m_sDBUSState.inhibitCookies.end()) - Debug::log(WARN, "BUG THIS: attempted to unregister unknown cookie"); - else - m_sDBUSState.inhibitCookies.erase(IT); + return false; + + m_sDBUSState.inhibitCookies.erase(IT); + return true; } -void handleDbusLogin(sdbus::Message& msg) { +bool CHypridle::unregisterDbusInhibitCookies(const std::string& ownerID) { + const auto IT = std::remove_if(m_sDBUSState.inhibitCookies.begin(), m_sDBUSState.inhibitCookies.end(), + [&ownerID](const CHypridle::SDbusInhibitCookie& item) { return item.ownerID == ownerID; }); + + if (IT == m_sDBUSState.inhibitCookies.end()) + return false; + + m_sDBUSState.inhibitCookies.erase(IT, m_sDBUSState.inhibitCookies.end()); + return true; +} + +static void handleDbusLogin(sdbus::Message msg) { // lock & unlock static auto* const PLOCKCMD = (Hyprlang::STRING const*)g_pConfigManager->getValuePtr("general:lock_cmd"); static auto* const PUNLOCKCMD = (Hyprlang::STRING const*)g_pConfigManager->getValuePtr("general:unlock_cmd"); Debug::log(LOG, "Got dbus .Session"); - const auto MEMBER = msg.getMemberName(); + const std::string MEMBER = msg.getMemberName(); if (MEMBER == "Lock") { Debug::log(LOG, "Got Lock from dbus"); @@ -360,8 +381,8 @@ } } -void handleDbusSleep(sdbus::Message& msg) { - const auto MEMBER = msg.getMemberName(); +static void handleDbusSleep(sdbus::Message msg) { + const std::string MEMBER = msg.getMemberName(); if (MEMBER != "PrepareForSleep") return; @@ -383,83 +404,141 @@ spawn(cmd); } -void handleDbusScreensaver(sdbus::MethodCall call, bool inhibit) { - std::string app = "?", reason = "?"; +void handleDbusBlockInhibits(const std::string& inhibits) { + static auto inhibited = false; + // BlockInhibited is a colon separated list of inhibit types. Wrapping in additional colons allows for easier checking if there are active inhibits we are interested in + auto inhibits_ = ":" + inhibits + ":"; + if (inhibits_.contains(":idle:")) { + if (!inhibited) { + inhibited = true; + Debug::log(LOG, "systemd idle inhibit active"); + g_pHypridle->onInhibit(true); + } + } else if (inhibited) { + inhibited = false; + Debug::log(LOG, "systemd idle inhibit inactive"); + g_pHypridle->onInhibit(false); + } +} - if (inhibit) { - call >> app; - call >> reason; - } else { - uint32_t cookie = 0; - call >> cookie; +static void handleDbusBlockInhibitsPropertyChanged(sdbus::Message msg) { + std::string interface; + std::map<std::string, sdbus::Variant> changedProperties; + msg >> interface >> changedProperties; + if (changedProperties.contains("BlockInhibited")) { + handleDbusBlockInhibits(changedProperties["BlockInhibited"].get<std::string>()); + } +} + +static uint32_t handleDbusScreensaver(std::string app, std::string reason, uint32_t cookie, bool inhibit, const char* sender) { + std::string ownerID = sender; + + if (!inhibit) { Debug::log(TRACE, "Read uninhibit cookie: {}", cookie); const auto COOKIE = g_pHypridle->getDbusInhibitCookie(cookie); if (COOKIE.cookie == 0) { Debug::log(WARN, "No cookie in uninhibit"); } else { - app = COOKIE.app; - reason = COOKIE.reason; - g_pHypridle->unregisterDbusInhibitCookie(COOKIE); + app = COOKIE.app; + reason = COOKIE.reason; + ownerID = COOKIE.ownerID; + + if (!g_pHypridle->unregisterDbusInhibitCookie(COOKIE)) + Debug::log(WARN, "BUG THIS: attempted to unregister unknown cookie"); } } - Debug::log(LOG, "ScreenSaver inhibit: {} dbus message from {} with content {}", inhibit, app, reason); + Debug::log(LOG, "ScreenSaver inhibit: {} dbus message from {} (owner: {}) with content {}", inhibit, app, ownerID, reason); - static auto* const PIGNORE = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:ignore_dbus_inhibit"); - - if (!**PIGNORE) { - if (inhibit) - g_pHypridle->onInhibit(true); - else - g_pHypridle->onInhibit(false); - } + if (inhibit) + g_pHypridle->onInhibit(true); + else + g_pHypridle->onInhibit(false); static int cookieID = 1337; if (inhibit) { - auto cookie = CHypridle::SDbusInhibitCookie{uint32_t{cookieID}, app, reason}; - - auto reply = call.createReply(); - reply << uint32_t{cookieID++}; - reply.send(); + auto cookie = CHypridle::SDbusInhibitCookie{uint32_t{cookieID}, app, reason, ownerID}; - Debug::log(LOG, "Cookie {} sent", cookieID - 1); + Debug::log(LOG, "Cookie {} sent", cookieID); g_pHypridle->registerDbusInhibitCookie(cookie); - } else { - auto reply = call.createReply(); - reply.send(); - Debug::log(TRACE, "Uninhibit response sent"); + + return cookieID++; + } + + return 0; +} + +static void handleDbusNameOwnerChanged(sdbus::Message msg) { + std::string name, oldOwner, newOwner; + msg >> name >> oldOwner >> newOwner; + + if (!newOwner.empty()) + return; + + if (g_pHypridle->unregisterDbusInhibitCookies(oldOwner)) { + Debug::log(LOG, "App with owner {} disconnected", oldOwner); + g_pHypridle->onInhibit(false); } } void CHypridle::setupDBUS() { - auto proxy = sdbus::createProxy("org.freedesktop.login1", "/org/freedesktop/login1"); - auto method = proxy->createMethodCall("org.freedesktop.login1.Manager", "GetSession"); - method << "auto"; + static auto const IGNORE_DBUS_INHIBIT = **(Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:ignore_dbus_inhibit"); + static auto const IGNORE_SYSTEMD_INHIBIT = **(Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:ignore_systemd_inhibit"); + + auto systemConnection = sdbus::createSystemBusConnection(); + auto proxy = sdbus::createProxy(*systemConnection, sdbus::ServiceName{"org.freedesktop.login1"}, sdbus::ObjectPath{"/org/freedesktop/login1"}); sdbus::ObjectPath path; try { - auto reply = proxy->callMethod(method); - reply >> path; - } catch (std::exception& e) { - Debug::log(CRIT, "Couldn't connect to logind service ({})", e.what()); - exit(1); - } + proxy->callMethod("GetSession").onInterface("org.freedesktop.login1.Manager").withArguments(std::string{"auto"}).storeResultsTo(path); + + m_sDBUSState.connection->addMatch("type='signal',path='" + path + "',interface='org.freedesktop.login1.Session'", ::handleDbusLogin); + m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager'", ::handleDbusSleep); + } catch (std::exception& e) { Debug::log(WARN, "Couldn't connect to logind service ({})", e.what()); } Debug::log(LOG, "Using dbus path {}", path.c_str()); - m_sDBUSState.connection->addMatch("type='signal',path='" + path + "',interface='org.freedesktop.login1.Session'", handleDbusLogin, sdbus::floating_slot_t{}); - m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager'", handleDbusSleep, sdbus::floating_slot_t{}); + if (!IGNORE_SYSTEMD_INHIBIT) { + m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.DBus.Properties'", ::handleDbusBlockInhibitsPropertyChanged); - // attempt to register as ScreenSaver - try { - m_sDBUSState.screenSaverServiceConnection = sdbus::createSessionBusConnection("org.freedesktop.ScreenSaver"); - m_sDBUSState.screenSaverObject = sdbus::createObject(*m_sDBUSState.screenSaverServiceConnection, "/org/freedesktop/ScreenSaver"); + try { + std::string value = (proxy->getProperty("BlockInhibited").onInterface("org.freedesktop.login1.Manager")).get<std::string>(); + handleDbusBlockInhibits(value); + } catch (std::exception& e) { Debug::log(WARN, "Couldn't retrieve current systemd inhibits ({})", e.what()); } + } + + if (!IGNORE_DBUS_INHIBIT) { + // attempt to register as ScreenSaver + std::string paths[] = { + "/org/freedesktop/ScreenSaver", + "/ScreenSaver", + }; + + try { + m_sDBUSState.screenSaverServiceConnection = sdbus::createSessionBusConnection(sdbus::ServiceName{"org.freedesktop.ScreenSaver"}); + + for (const std::string& path : paths) { + try { + auto obj = sdbus::createObject(*m_sDBUSState.screenSaverServiceConnection, sdbus::ObjectPath{path}); + + obj->addVTable(sdbus::registerMethod("Inhibit").implementedAs([object = obj.get()](std::string s1, std::string s2) { + return handleDbusScreensaver(s1, s2, 0, true, object->getCurrentlyProcessedMessage().getSender()); + }), + sdbus::registerMethod("UnInhibit").implementedAs([object = obj.get()](uint32_t c) { + handleDbusScreensaver("", "", c, false, object->getCurrentlyProcessedMessage().getSender()); + })) + .forInterface(sdbus::InterfaceName{"org.freedesktop.ScreenSaver"}); - m_sDBUSState.screenSaverObject->registerMethod("org.freedesktop.ScreenSaver", "Inhibit", "ss", "u", [&](sdbus::MethodCall c) { handleDbusScreensaver(c, true); }); - m_sDBUSState.screenSaverObject->registerMethod("org.freedesktop.ScreenSaver", "UnInhibit", "u", "", [&](sdbus::MethodCall c) { handleDbusScreensaver(c, false); }); + m_sDBUSState.screenSaverObjects.push_back(std::move(obj)); + } catch (std::exception& e) { Debug::log(ERR, "Failed registering for {}, perhaps taken?\nerr: {}", path, e.what()); } + } + + m_sDBUSState.screenSaverServiceConnection->addMatch("type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'", + ::handleDbusNameOwnerChanged); + } catch (std::exception& e) { Debug::log(ERR, "Couldn't connect to session dbus\nerr: {}", e.what()); } + } - m_sDBUSState.screenSaverObject->finishRegistration(); - } catch (std::exception& e) { Debug::log(ERR, "Failed registering for /org/freedesktop/ScreenSaver, perhaps taken?\nerr: {}", e.what()); } + systemConnection.reset(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/src/core/Hypridle.hpp new/hypridle-0.1.5/src/core/Hypridle.hpp --- old/hypridle-0.1.2/src/core/Hypridle.hpp 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/src/core/Hypridle.hpp 2024-11-02 16:29:47.000000000 +0100 @@ -20,7 +20,7 @@ struct SDbusInhibitCookie { uint32_t cookie = 0; - std::string app, reason; + std::string app, reason, ownerID; }; void run(); @@ -35,7 +35,8 @@ SDbusInhibitCookie getDbusInhibitCookie(uint32_t cookie); void registerDbusInhibitCookie(SDbusInhibitCookie& cookie); - void unregisterDbusInhibitCookie(const SDbusInhibitCookie& cookie); + bool unregisterDbusInhibitCookie(const SDbusInhibitCookie& cookie); + bool unregisterDbusInhibitCookies(const std::string& ownerID); private: void setupDBUS(); @@ -58,10 +59,10 @@ } m_sWaylandIdleState; struct { - std::unique_ptr<sdbus::IConnection> connection; - std::unique_ptr<sdbus::IConnection> screenSaverServiceConnection; - std::unique_ptr<sdbus::IObject> screenSaverObject; - std::vector<SDbusInhibitCookie> inhibitCookies; + std::unique_ptr<sdbus::IConnection> connection; + std::unique_ptr<sdbus::IConnection> screenSaverServiceConnection; + std::vector<std::unique_ptr<sdbus::IObject>> screenSaverObjects; + std::vector<SDbusInhibitCookie> inhibitCookies; } m_sDBUSState; struct { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/src/helpers/Log.hpp new/hypridle-0.1.5/src/helpers/Log.hpp --- old/hypridle-0.1.2/src/helpers/Log.hpp 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/src/helpers/Log.hpp 2024-11-02 16:29:47.000000000 +0100 @@ -53,6 +53,6 @@ std::cout << "] "; } - std::cout << std::vformat(fmt, std::make_format_args(args...)) << "\n"; + std::cout << std::vformat(fmt, std::make_format_args(args...)) << std::endl; } }; \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypridle-0.1.2/src/main.cpp new/hypridle-0.1.5/src/main.cpp --- old/hypridle-0.1.2/src/main.cpp 2024-04-18 22:34:42.000000000 +0200 +++ new/hypridle-0.1.5/src/main.cpp 2024-11-02 16:29:47.000000000 +0100 @@ -1,6 +1,7 @@ #include "config/ConfigManager.hpp" #include "core/Hypridle.hpp" +#include "helpers/Log.hpp" int main(int argc, char** argv, char** envp) { std::string configPath; @@ -15,7 +16,21 @@ Debug::quiet = true; else if (arg == "--config" || arg == "-c") { + if (i + 1 >= argc) { + Debug::log(NONE, "After " + arg + " you should provide a path to a config file."); + return 1; + } + + if (!configPath.empty()) { + Debug::log(NONE, "Multiple config files are provided."); + return 1; + } + configPath = argv[++i]; + if (configPath[0] == '-') { // Should be fine, because of the null terminator + Debug::log(NONE, "After " + arg + " you should provide a path to a config file."); + return 1; + } } } ++++++ hypridle.obsinfo ++++++ --- /var/tmp/diff_new_pack.CJUA2w/_old 2024-12-20 23:12:35.173335568 +0100 +++ /var/tmp/diff_new_pack.CJUA2w/_new 2024-12-20 23:12:35.177335733 +0100 @@ -1,5 +1,5 @@ name: hypridle -version: 0.1.2 -mtime: 1713472482 -commit: 7cff4581a3753154fc5b41f39a098fad49b777b1 +version: 0.1.5 +mtime: 1730561387 +commit: 26780ac51f6e7273e3934885036b7a7ed1a5af01
