summaryrefslogtreecommitdiff
path: root/repo/acpid/handler.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-05-31 11:05:19 +0100
committerdavidovski <david@davidovski.xyz>2022-05-31 11:05:19 +0100
commit48ca75555522716f0f686dcae3dd6cf3d8ad714d (patch)
tree00c0f58550ba4661e87376f2f02c8001c69bae44 /repo/acpid/handler.sh
parent871b2b573f01c1b3176a0f65458b3d281b41c437 (diff)
removed idea of repos
Diffstat (limited to 'repo/acpid/handler.sh')
-rw-r--r--repo/acpid/handler.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/repo/acpid/handler.sh b/repo/acpid/handler.sh
new file mode 100644
index 0000000..412ac02
--- /dev/null
+++ b/repo/acpid/handler.sh
@@ -0,0 +1,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