commit swayidle for openSUSE:Factory
Hello community, here is the log from the commit of package swayidle for openSUSE:Factory checked in at 2019-05-24 11:31:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/swayidle (Old) and /work/SRC/openSUSE:Factory/.swayidle.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "swayidle" Fri May 24 11:31:37 2019 rev:2 rq:704917 version:1.3 Changes: -------- --- /work/SRC/openSUSE:Factory/swayidle/swayidle.changes 2019-02-25 17:50:47.106771824 +0100 +++ /work/SRC/openSUSE:Factory/.swayidle.new.5148/swayidle.changes 2019-05-24 11:31:39.813402162 +0200 @@ -1,0 +2,9 @@ +Thu May 23 06:13:01 UTC 2019 - mvetter@suse.com + +- Update to 1.3: + * Add an error message when before-sleep is used without dbus support + * Add support for logind's lock/unlock signals + * Set version in project file +- Add swayidle-version.patch: they forgot to increase the version + +------------------------------------------------------------------- Old: ---- 1.2.tar.gz New: ---- 1.3.tar.gz swayidle-version.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ swayidle.spec ++++++ --- /var/tmp/diff_new_pack.Nd9cIF/_old 2019-05-24 11:31:41.101401831 +0200 +++ /var/tmp/diff_new_pack.Nd9cIF/_new 2019-05-24 11:31:41.109401828 +0200 @@ -12,18 +12,19 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: swayidle -Version: 1.2 +Version: 1.3 Release: 0 Summary: Idle management daemon for Wayland License: MIT Group: System/GUI/Other URL: https://github.com/swaywm/swayidle Source0: https://github.com/swaywm/swayidle/archive/%{version}.tar.gz +Patch0: swayidle-version.patch BuildRequires: meson >= 0.48.0 BuildRequires: pkgconfig BuildRequires: scdoc @@ -67,6 +68,7 @@ %prep %setup -q +%patch0 -p1 %build export CFLAGS="%{optflags} -I/usr/include/wayland" ++++++ 1.2.tar.gz -> 1.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swayidle-1.2/main.c new/swayidle-1.3/main.c --- old/swayidle-1.2/main.c 2019-01-27 14:22:09.000000000 +0100 +++ new/swayidle-1.3/main.c 2019-02-16 17:43:36.000000000 +0100 @@ -33,6 +33,8 @@ struct wl_list timeout_cmds; // struct swayidle_timeout_cmd * char *before_sleep_cmd; char *after_resume_cmd; + char *logind_lock_cmd; + char *logind_unlock_cmd; bool wait; } state; @@ -109,6 +111,7 @@ #if HAVE_SYSTEMD || HAVE_ELOGIND static int lock_fd = -1; static struct sd_bus *bus = NULL; +static char *session_name = NULL; static void acquire_sleep_lock(void) { sd_bus_message *msg = NULL; @@ -178,6 +181,29 @@ return 0; } +static int handle_lock(sd_bus_message *msg, void *userdata, + sd_bus_error *ret_error) { + swayidle_log(LOG_DEBUG, "Lock signal received"); + + if (state.logind_lock_cmd) { + cmd_exec(state.logind_lock_cmd); + } + swayidle_log(LOG_DEBUG, "Lock command done"); + + return 0; +} + +static int handle_unlock(sd_bus_message *msg, void *userdata, + sd_bus_error *ret_error) { + swayidle_log(LOG_DEBUG, "Unlock signal received"); + + if (state.logind_unlock_cmd) { + cmd_exec(state.logind_unlock_cmd); + } + swayidle_log(LOG_DEBUG, "Unlock command done"); + + return 0; +} static int dbus_event(int fd, uint32_t mask, void *data) { sd_bus *bus = data; @@ -205,27 +231,74 @@ return count; } -static void setup_sleep_listener(void) { +static void connect_to_bus(void) { int ret = sd_bus_default_system(&bus); + sd_bus_message *msg = NULL; + sd_bus_error error = SD_BUS_ERROR_NULL; + pid_t my_pid = getpid(); + const char *session_name_tmp; if (ret < 0) { errno = -ret; swayidle_log_errno(LOG_ERROR, "Failed to open D-Bus connection"); return; } + struct wl_event_source *source = wl_event_loop_add_fd(state.event_loop, + sd_bus_get_fd(bus), WL_EVENT_READABLE, dbus_event, bus); + wl_event_source_check(source); + ret = sd_bus_call_method(bus, "org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", "GetSessionByPID", + &error, &msg, "u", my_pid); + if (ret < 0) { + swayidle_log(LOG_ERROR, + "Failed to find session name: %s", error.message); + goto cleanup; + } + + ret = sd_bus_message_read(msg, "o", &session_name_tmp); + if (ret < 0) { + swayidle_log(LOG_ERROR, + "Failed to read session name\n"); + goto cleanup; + } + session_name = strdup(session_name_tmp); +cleanup: + sd_bus_error_free(&error); + sd_bus_message_unref(msg); +} - ret = sd_bus_match_signal(bus, NULL, "org.freedesktop.login1", +static void setup_sleep_listener(void) { + int ret = sd_bus_match_signal(bus, NULL, "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", prepare_for_sleep, NULL); if (ret < 0) { errno = -ret; - swayidle_log_errno(LOG_ERROR, "Failed to add D-Bus signal match"); + swayidle_log_errno(LOG_ERROR, "Failed to add D-Bus signal match : sleep"); return; } acquire_sleep_lock(); +} - struct wl_event_source *source = wl_event_loop_add_fd(state.event_loop, - sd_bus_get_fd(bus), WL_EVENT_READABLE, dbus_event, bus); - wl_event_source_check(source); +static void setup_lock_listener(void) { + int ret = sd_bus_match_signal(bus, NULL, "org.freedesktop.login1", + session_name, "org.freedesktop.login1.Session", + "Lock", handle_lock, NULL); + if (ret < 0) { + errno = -ret; + swayidle_log_errno(LOG_ERROR, "Failed to add D-Bus signal match : lock"); + return; + } +} + +static void setup_unlock_listener(void) { + int ret = sd_bus_match_signal(bus, NULL, "org.freedesktop.login1", + session_name, "org.freedesktop.login1.Session", + "Unlock", handle_unlock, NULL); + if (ret < 0) { + errno = -ret; + swayidle_log_errno(LOG_ERROR, "Failed to add D-Bus signal match : unlock"); + return; + } } #endif @@ -342,6 +415,11 @@ } static int parse_sleep(int argc, char **argv) { +#if !HAVE_SYSTEMD && !HAVE_ELOGIND + swayidle_log(LOG_ERROR, "before-sleep not supported: swayidle was compiled " + "with neither systemd nor elogind support."); + exit(-1); +#endif if (argc < 2) { swayidle_log(LOG_ERROR, "Too few parameters to before-sleep command. " "Usage: before-sleep <command>"); @@ -357,6 +435,11 @@ } static int parse_resume(int argc, char **argv) { +#if !HAVE_SYSTEMD && !HAVE_ELOGIND + swayidle_log(LOG_ERROR, "after-resume not supported: swayidle was compiled " + "with neither systemd nor elogind support."); + exit(-1); +#endif if (argc < 2) { swayidle_log(LOG_ERROR, "Too few parameters to after-resume command. " "Usage: after-resume <command>"); @@ -371,6 +454,46 @@ return 2; } +static int parse_lock(int argc, char **argv) { +#if !HAVE_SYSTEMD && !HAVE_ELOGIND + swayidle_log(LOG_ERROR, "lock not supported: swayidle was compiled" + " with neither systemd nor elogind support."); + exit(-1); +#endif + if (argc < 2) { + swayidle_log(LOG_ERROR, "Too few parameters to lock command. " + "Usage: lock <command>"); + exit(-1); + } + + state.logind_lock_cmd = parse_command(argc - 1, &argv[1]); + if (state.logind_lock_cmd) { + swayidle_log(LOG_DEBUG, "Setup lock hook: %s", state.logind_lock_cmd); + } + + return 2; +} + +static int parse_unlock(int argc, char **argv) { +#if !HAVE_SYSTEMD && !HAVE_ELOGIND + swayidle_log(LOG_ERROR, "unlock not supported: swayidle was compiled" + " with neither systemd nor elogind support."); + exit(-1); +#endif + if (argc < 2) { + swayidle_log(LOG_ERROR, "Too few parameters to unlock command. " + "Usage: unlock <command>"); + exit(-1); + } + + state.logind_unlock_cmd = parse_command(argc - 1, &argv[1]); + if (state.logind_unlock_cmd) { + swayidle_log(LOG_DEBUG, "Setup unlock hook: %s", state.logind_unlock_cmd); + } + + return 2; +} + static int parse_args(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "hdw")) != -1) { @@ -406,6 +529,12 @@ } else if (!strcmp("after-resume", argv[i])) { swayidle_log(LOG_DEBUG, "Got after-resume"); i += parse_resume(argc - i, &argv[i]); + } else if (!strcmp("lock", argv[i])) { + swayidle_log(LOG_DEBUG, "Got lock"); + i += parse_lock(argc - i, &argv[i]); + } else if (!strcmp("unlock", argv[i])) { + swayidle_log(LOG_DEBUG, "Got unlock"); + i += parse_unlock(argc - i, &argv[i]); } else { swayidle_log(LOG_ERROR, "Unsupported command '%s'", argv[i]); return 1; @@ -491,10 +620,19 @@ bool should_run = !wl_list_empty(&state.timeout_cmds); #if HAVE_SYSTEMD || HAVE_ELOGIND + connect_to_bus(); if (state.before_sleep_cmd || state.after_resume_cmd) { should_run = true; setup_sleep_listener(); } + if (state.logind_lock_cmd) { + should_run = true; + setup_lock_listener(); + } + if (state.logind_unlock_cmd) { + should_run = true; + setup_unlock_listener(); + } #endif if (!should_run) { swayidle_log(LOG_INFO, "No command specified! Nothing to do, will exit"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swayidle-1.2/meson.build new/swayidle-1.3/meson.build --- old/swayidle-1.2/meson.build 2019-01-27 14:22:09.000000000 +0100 +++ new/swayidle-1.3/meson.build 2019-02-16 17:43:36.000000000 +0100 @@ -1,6 +1,7 @@ project( 'swayidle', 'c', + version: '1.2', license: 'MIT', meson_version: '>=0.48.0', default_options: [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swayidle-1.2/swayidle.1.scd new/swayidle-1.3/swayidle.1.scd --- old/swayidle-1.2/swayidle.1.scd 2019-01-27 14:22:09.000000000 +0100 +++ new/swayidle-1.3/swayidle.1.scd 2019-02-16 17:43:36.000000000 +0100 @@ -50,6 +50,14 @@ If built with systemd support, executes _command_ after logind signals that the computer resumed from sleep. +*lock* <command> + If built with systemd support, executes _command_ when logind signals that the + session should be locked + +*unlock* <command> + If built with systemd support, executes _command_ when logind signals that the + session should be unlocked + All commands are executed in a shell. # EXAMPLE @@ -77,4 +85,4 @@ # SEE ALSO -*sway*(5) *swaymsg*(1) *sway-input*(5) *sway-output*(5) *sway-bar*(5) +*sway*(5) *swaymsg*(1) *sway-input*(5) *sway-output*(5) *sway-bar*(5) *loginctl*(1) ++++++ swayidle-version.patch ++++++ diff -urEbw swayidle-1.3/meson.build swayidle-1.3.new/meson.build --- swayidle-1.3/meson.build 2019-02-16 17:43:36.000000000 +0100 +++ swayidle-1.3.new/meson.build 2019-05-23 08:14:03.661720253 +0200 @@ -1,7 +1,7 @@ project( 'swayidle', 'c', - version: '1.2', + version: '1.3', license: 'MIT', meson_version: '>=0.48.0', default_options: [
participants (1)
-
root