summaryrefslogtreecommitdiff
path: root/repo/system/acpid/handler.sh
blob: 412ac023112f5b7203218ae946cee999b64bb02c (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
30
31
32
33
34
35
36
#!/bin/sh
# vim: set ts=4:
#
# This is the default ACPI handler script that is configured in
# /etc/acpi/events/anything to be called for every ACPI event.
# You can edit it and add your own actions; treat it as a configuration file.
#
PATH="/usr/share/acpid:$PATH"
alias log='logger -t acpid'

# <dev-class>:<dev-name>:<notif-value>:<sup-value>
case "$1:$2:$3:$4" in

button/power:PWRF:*)
	log 'Power button pressed'
	# Shutdown the system unless it has a lid (notebook).
	[ -e /proc/acpi/button/lid/LID ] || poweroff
;;
button/sleep:SLPB:*)
	log 'Sleep button pressed'
	# Suspend to RAM.
	zzz
;;
button/lid:*:close:*)
	log 'Lid closed'
	# Suspend to RAM if AC adapter is not connected.
	power-supply-ac || zzz
;;
ac_adapter:*:*:*0)
	log 'AC adapter unplugged'
	# Suspend to RAM if notebook's lid is closed.
	lid-closed && zzz
;;
esac

exit 0