aboutsummaryrefslogtreecommitdiffstats
path: root/acpid
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-04-20 20:25:14 +0000
committerterminaldweller <thabogre@gmail.com>2022-04-20 20:25:14 +0000
commit6df53c23edd3817d7861d98aee087c8c2bec8be8 (patch)
tree28e19bdf552cf955126619e0be2a2fff6cf40a77 /acpid
parentbunch of stuff (diff)
downloadscripts-6df53c23edd3817d7861d98aee087c8c2bec8be8.tar.gz
scripts-6df53c23edd3817d7861d98aee087c8c2bec8be8.zip
update
Diffstat (limited to 'acpid')
-rwxr-xr-xacpid/handler.sh102
1 files changed, 102 insertions, 0 deletions
diff --git a/acpid/handler.sh b/acpid/handler.sh
new file mode 100755
index 0000000..6a66e1d
--- /dev/null
+++ b/acpid/handler.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+# Default acpi script that takes an entry for all actions
+
+# NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to
+# modify it to not use /sys
+
+# $1 should be + or - to step up or down the brightness.
+step_backlight() {
+ for backlight in /sys/class/backlight/*/; do
+ [ -d "$backlight" ] || continue
+ step=$(( $(cat "$backlight/max_brightness") / 20 ))
+ [ "$step" -gt "1" ] || step=1 #fallback if gradation is too low
+ printf '%s' "$(( $(cat "$backlight/brightness") $1 step ))" >"$backlight/brightness"
+ done
+}
+
+minspeed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq)
+maxspeed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
+setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
+
+
+case "$1" in
+ button/power)
+ case "$2" in
+ PBTN|PWRF)
+ logger "PowerButton pressed: $2, shutting down..."
+ shutdown -P now
+ ;;
+ *) logger "button/power ACPI action undefined: $2" ;;
+ esac
+ ;;
+ button/sleep)
+ case "$2" in
+ SBTN|SLPB)
+ # suspend-to-ram
+ logger "Sleep Button pressed: $2, suspending..."
+ zzz
+ ;;
+ *) logger "button/sleep ACPI action undefined: $2" ;;
+ esac
+ ;;
+ ac_adapter)
+ case "$2" in
+ AC|ACAD|ADP0)
+ case "$4" in
+ 00000000)
+ printf '%s' "$minspeed" >"$setspeed"
+ #/etc/laptop-mode/laptop-mode start
+ ;;
+ 00000001)
+ printf '%s' "$maxspeed" >"$setspeed"
+ #/etc/laptop-mode/laptop-mode stop
+ ;;
+ esac
+ ;;
+ *) logger "ac_adapter ACPI action undefined: $2" ;;
+ esac
+ ;;
+ battery)
+ case "$2" in
+ BAT0)
+ case "$4" in
+ 00000000) #echo "offline" >/dev/tty5
+ ;;
+ 00000001) #echo "online" >/dev/tty5
+ ;;
+ esac
+ ;;
+ CPU0)
+ ;;
+ PNP0C0A*)
+ :
+ ;;
+ *) logger "battery ACPI action undefined: $2" ;;
+ esac
+ ;;
+ button/lid)
+ case "$3" in
+ close)
+ # suspend-to-ram
+ logger "LID closed, suspending..."
+ zzz
+ ;;
+ open)
+ logger "LID opened"
+ ;;
+ *) logger "button/lid ACPI action undefined (LID): $2";;
+ esac
+ ;;
+ video/brightnessdown)
+ step_backlight -
+ ;;
+ video/brightnessup)
+ step_backlight +
+ ;;
+ processor)
+ :
+ ;;
+ *)
+ logger "ACPI group/action undefined: $1 / $2"
+ ;;
+esac