diff options
-rwxr-xr-x | kanotix-power-button/powerbtn-kanotix.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/kanotix-power-button/powerbtn-kanotix.sh b/kanotix-power-button/powerbtn-kanotix.sh new file mode 100755 index 0000000..ed096e6 --- /dev/null +++ b/kanotix-power-button/powerbtn-kanotix.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# /etc/acpi/powerbtn-kanotix.sh + +# workaround for xfce4-power-manager in LXDE +# when power-button-is pressed and options are set to ask +# +# more info debian/README.Debian + +pidof lxsession > /dev/null || exit 1 # only start in LXDE +[ -x /usr/bin/xfce4-power-manager ] || exit 2 # only with xfce4-power-manager +pidof lxsession-logout > /dev/null && exit 3 # only start once + +getuser () + { + export DISPLAY=:0 + user=`who|awk '/'"$DISPLAY"/'{print $1}'|head -1` + logger "Powerbtn: user $user pushed powerbutton" + export XAUTHORITY=/home/$user/.Xauthority +} + +getuser "$user" +# only when option is set to ask +if grep -qs '<property name="power-button-action" type="uint" value="3"/>' /home/$user/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml + then + export _LXSESSION_PID=`pidof lxsession` + logger "Powerbtn: user $user requested logout screen" + su $user -c "/usr/bin/lxde-logout" & +fi |