File: lid.sh

package info (click to toggle)
acpi-support 0.142-8
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 788 kB
  • sloc: sh: 1,068; ansic: 131; makefile: 33
file content (59 lines) | stat: -rw-r--r-- 1,457 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

test -f /usr/share/acpi-support/state-funcs || exit 0

. /usr/share/acpi-support/power-funcs
. /usr/share/acpi-support/policy-funcs
. /etc/default/acpi-support

[ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre

if { CheckPolicy || HasLogindAndSystemd1Manager; }; then
	exit
fi

grep -q closed /proc/acpi/button/lid/*/state
if [ $? -eq 0 ]
then
    . /usr/share/acpi-support/screenblank
    if [ x$LID_SLEEP = xtrue ]; then
	pm-suspend
	if [ $? -ne 0 -a x$LID_SHUTDOWN = xtrue ]; then
		shutdown -P now
	fi
    fi
else
    d=/tmp/.X11-unix
    for x in $d/X*; do
	displaynum=${x#$d/X}
	getXuser;
	if [ x$XAUTHORITY != x ]; then
	    export DISPLAY=":$displaynum"
	    if [ x$RADEON_LIGHT = xtrue ]; then
		[ -x /usr/sbin/radeontool ] && radeontool light on
	    fi
	    case "$DISPLAY_DPMS" in
		xset)
			su "$XUSER" -s /bin/sh -c "xset dpms force on"
			;;
		xrandr)
			su "$XUSER" -s /bin/sh -c "xrandr --output $XRANDR_OUTPUT --auto"
			;;
		vbetool)
			/usr/sbin/vbetool dpms on
			;;
	    esac
	    if pidof xscreensaver > /dev/null; then
	        if on_ac_power; then 
		    su "$XUSER" -s /bin/sh -c "xscreensaver-command -unthrottle"
		fi
		su "$XUSER" -s /bin/sh -c "xscreensaver-command -deactivate"
	    fi
	else
	    if [ -x$DISPLAY_DPMS_NO_USER = xtrue ]; then
            	[ -x /usr/sbin/vbetool ] && /usr/sbin/vbetool dpms on
	    fi 
	fi
    done
fi
[ -x /etc/acpi/local/lid.sh.post ] && /etc/acpi/local/lid.sh.post