From 93c7c8c0e35f0b2b9a355a727027c4c4ad6d0e6a6c85c9d823f75b6778af730b Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Wed, 14 Aug 2013 09:33:11 +0000 Subject: [PATCH] Accepting request 186826 from home:michael-chang:bnc810125 - power_button: iterate systemd-logind sessions and do nothing if a active X session found (bnc#810125) OBS-URL: https://build.opensuse.org/request/show/186826 OBS-URL: https://build.opensuse.org/package/show/Base:System/acpid?expand=0&rev=63 --- acpid.changes | 6 ++++++ power_button | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/acpid.changes b/acpid.changes index 036c056..f877102 100644 --- a/acpid.changes +++ b/acpid.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Aug 13 06:44:10 UTC 2013 - mchang@suse.com + +- power_button: iterate systemd-logind sessions and do nothing if a + active X session found (bnc#810125) + ------------------------------------------------------------------- Fri Aug 2 11:56:14 UTC 2013 - werner@suse.de diff --git a/power_button b/power_button index 46823b2..ebdf2f9 100644 --- a/power_button +++ b/power_button @@ -54,5 +54,28 @@ while read A; do fi done < <(ck-list-sessions) +# iterate over all sessions. If a active X session is found, do nothing +# bnc#810125 - 12.3 power button always halts system instead suspend +# similar to consolekit checks, this time we check systemd-logind sessions +while read SESSION DUMMY ; do + + # check if this is a X session, if not, go on + DISP=`loginctl --property=Display show-session $SESSION` + DISP=`echo $DISP | sed -e 's/^Display=//'` + [ -n "$DISP" ] || continue + + STATE=`loginctl --property=State show-session $SESSION` + STATE=`echo $STATE | sed -e 's/^State=//'` + + if [ "$STATE" = "active" -a -n "$DISP" ]; then + # additional check, if none of these two apps are running, go on + if [ -n "`pidof kpowersave`" -o -n "`pidof gnome-power-manager`" -o -n "`pidof kded4`" -o -n "`pidof dalston-power-applet`" -o -n "`pidof gnome-settings-daemon`" ]; then + echo doing nothing... + exit 0 + fi + fi + +done < <(loginctl list-sessions) + logger -s -t pm-profiler "Power Button pressed, executing $EXEC" $EXEC