add acpi handler
This commit is contained in:
parent
8c528fea32
commit
6858febb05
|
@ -0,0 +1,98 @@
|
|||
#!/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, suspending..."
|
||||
pgrep swaylock ||
|
||||
pkill -SIGUSR1 swayidle
|
||||
zzz
|
||||
;;
|
||||
*) logger "ACPI action undefined: $2" ;;
|
||||
esac
|
||||
;;
|
||||
button/sleep)
|
||||
case "$2" in
|
||||
SBTN|SLPB)
|
||||
# suspend-to-ram
|
||||
logger "Sleep Button pressed: $2, suspending..."
|
||||
zzz
|
||||
;;
|
||||
*) logger "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 "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)
|
||||
;;
|
||||
*) logger "ACPI action undefined: $2" ;;
|
||||
esac
|
||||
;;
|
||||
button/lid)
|
||||
case "$3" in
|
||||
close)
|
||||
# suspend-to-ram
|
||||
logger "LID closed, suspending..."
|
||||
# zzz
|
||||
;;
|
||||
open)
|
||||
logger "LID opened"
|
||||
;;
|
||||
*) logger "ACPI action undefined (LID): $2";;
|
||||
esac
|
||||
;;
|
||||
video/brightnessdown)
|
||||
step_backlight -
|
||||
;;
|
||||
video/brightnessup)
|
||||
step_backlight +
|
||||
;;
|
||||
*)
|
||||
logger "ACPI group/action undefined: $1 / $2"
|
||||
;;
|
||||
esac
|
|
@ -43,6 +43,7 @@ actions:
|
|||
dbus_uuidgen: dbus-uuidgen --ensure
|
||||
sysctl_apply: sysctl -a
|
||||
mkinitcpio: mkinitcpio -P
|
||||
restart_runit_service: sv restart "{0}"
|
||||
enable_runit_services: ln -sf "{{@@ sys_services @@}}/{0}" "{{@@ sys_svdir @@}}/{0}"
|
||||
|
||||
###############################################################
|
||||
|
@ -71,6 +72,7 @@ profiles:
|
|||
- "common"
|
||||
dotfiles:
|
||||
- elogind
|
||||
- acpid
|
||||
- libc_locales
|
||||
- runit_services
|
||||
- runit_services_enable
|
||||
|
@ -119,6 +121,12 @@ dotfiles:
|
|||
actions:
|
||||
- dbus_uuidgen
|
||||
|
||||
acpid:
|
||||
src: acpi-handler.sh
|
||||
dst: /etc/acpi/handler.sh
|
||||
actions:
|
||||
- restart_runit_service acpid
|
||||
|
||||
grub:
|
||||
src: grub
|
||||
dst: /etc/default/grub
|
||||
|
|
Reference in New Issue