updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / acpi-eee904 / ap-button.sh
blob1e0a1149c233a50e294db72355320d460bfdd729
1 #!/bin/sh
2 # Following script is executed once the "AP"- or
3 # "Task manager"-button is pressed
5 source /etc/acpi/eee.conf
7 if [ -S /tmp/.X11-unix/X0 ]; then
8 export DISPLAY=:0
9 user=$(who | grep "vc/7" | awk '{ if ($(NF) == "(:0)") print $1 }')
10 if [ "$user" = "" ];
11 then
12 logger "Could not verify user for X:"
13 logger $(who)
14 logger "Falling back to XUSER: $XUSER"
15 user="$XUSER"
16 else
17 logger "Found X session user: $user"
19 XAUTHORITY=/home/$user/.Xauthority
20 [ -f $XAUTHORITY ] && export XAUTHORITY
21 else
22 logger "X not probably running, lets launch the command anyway"
23 user="$XUSER"
26 logger "Executing $AP_COMMAND as $user"
27 su $user --login -c "$AP_COMMAND" &