acpi-handler.sh (1212B)
1 #!/bin/sh 2 # vim: set ts=4: 3 # 4 # This is the default ACPI handler script that is configured in 5 # /etc/acpi/events/anything to be called for every ACPI event. 6 # You can edit it and add your own actions; treat it as a configuration file. 7 # 8 PATH="/usr/share/acpid:$PATH" 9 alias log='logger -t acpid' 10 11 # <dev-class>:<dev-name>:<notif-value>:<sup-value> 12 case "$1:$2:$3:$4" in 13 14 button/power:PWRF:*) 15 log 'Power button pressed' 16 # Shutdown the system unless it has a lid (notebook). 17 [ -e /proc/acpi/button/lid/LID ] || poweroff 18 ;; 19 button/sleep:SLPB:*) 20 log 'Sleep button pressed' 21 # Suspend to RAM. 22 zzz 23 ;; 24 button/lid:*:close:*) 25 log 'Lid closed' 26 # Suspend to RAM if AC adapter is not connected. 27 power-supply-ac || zzz 28 ;; 29 ac_adapter:*:*:*0) 30 log 'AC adapter unplugged' 31 # Suspend to RAM if notebook's lid is closed. 32 lid-closed && zzz 33 ;; 34 button/volumeup:VOLUP:*) 35 log 'Increase volume 5%' 36 /usr/bin/amixer sset 'Master',0 '5%+' 37 ;; 38 button/volumedown:VOLDN:*) 39 log 'Decrease volume 5%' 40 /usr/bin/amixer sset 'Master',0 '5%-' 41 ;; 42 button/mute:MUTE:*) 43 log 'Toggle audio mute' 44 /usr/bin/amixer sset 'Master',0 toggle 45 ;; 46 button/f20:F20:*) 47 log 'Toggle microphone mute' 48 /usr/bin/amixer sset 'Capture',0 toggle 49 ;; 50 esac 51 52 exit 0