summaryrefslogtreecommitdiff
path: root/kanotix-power-button/powerbtn-kanotix.sh
blob: b420400dea12fa07cca5f0dd3dd69e895f9874e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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=`ps aux|awk '/\/usr\/bin\/lxsession/{print $1}'|head -1`
     logger "Powerbtn: user $user pushed powerbutton"
     export XAUTHORITY=/home/$user/.Xauthority
}

getuser
# 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"
    /bin/su $user -c "/usr/bin/lxsession-logout --banner /usr/share/lxde/images/logout-banner.png --side=top" &
fi