--- Desktop/eeepc-acpi-scripts/eeepc-acpi-scripts/actions/hotkey.sh 2008-04-25 14:29:09.000000000 +0200 +++ /etc/acpi/actions/hotkey.sh 2008-06-12 10:26:23.000000000 +0200 @@ -10,9 +10,8 @@ echo "$@" # for /var/log/acpid if [ -S /tmp/.X11-unix/X0 ]; then export DISPLAY=:0 - user=$(who | sed -n '/ (:0[\.0]*)$\| :0 /{s/ .*//p;q}') - home=$(getent passwd $user | cut -d: -f6) - XAUTHORITY=$home/.Xauthority + user=$(who | sed -n '/ (:0[\.0].*)$\| :0 /{s/ .*//p;q}') + XAUTHORITY=/home/$user/.Xauthority [ -f $XAUTHORITY ] && export XAUTHORITY if [ "x$ENABLE_OSD" = "xno" ]; then @@ -20,16 +19,13 @@ fi killall -q aosd_cat - if [ -n "$2" -a -z "$(echo $2 | sed 's/[0-9]//g')" ]; then - echo "$@%" | aosd_cat -f 0 -u 100 -o 0 -n "$OSD_FONT" & - else - echo "$@" | aosd_cat -n "$OSD_FONT" -f 100 -u 1000 -o 100 & - fi + echo "$@" | aosd_cat -n "$OSD_FONT" -f 80 -u 1000 -o 80 -e 0 -b 155 -B $OSD_BG_COLOR -R $OSD_COLOR -x $OSD_X -y $OSD_Y & else echo "$@" > /dev/console fi } + show_wireless() { if grep -q ath0 /proc/net/wireless; then status=On @@ -46,16 +42,29 @@ show_volume() { percent=$(amixer get $VOLUME_LABEL | sed -n '/%/{s/.*\[\(.*\)%\].*/\1/p;q}') - notify Volume $percent + notify Volume $percent% +} + +show_brightness() { + # final digit of ACPI code is brightness level in hex + level=$(cat /proc/acpi/asus/brn) + # convert hex digit to percent + percent=$(((100 * $level + 8) / 15)) + notify Brightness $percent% } -#show_brightness() { -# # final digit of ACPI code is brightness level in hex -# level=0x${code:${#code}-1} -# # convert hex digit to percent -# percent=$(((100 * $level + 8) / 15)) -# notify Brightness $percent -#} +show_vga() { + notify "" + status=$(xrandr -q | grep VGA | cut -d ' ' -f 1,2,3 ) + notify ${status%(*} +} + +show_batt() { + status=$(cat /proc/acpi/battery/BAT0/state | grep 'charging') + percent=$(cat /proc/acpi/battery/BAT0/state | grep 'remaining capacity') + percent=${percent%*mAh} + notify Batt.${status#*:}: ${percent#*:}% +} case $code in # Fn+F2 -- toggle wireless @@ -77,24 +86,41 @@ ;; # Fn+F8 -- decrease volume 00000014) - amixer -q set $VOLUME_LABEL 2- unmute + amixer -q set $VOLUME_LABEL 4- unmute amixer -q set $HEADPHONE_LABEL on show_volume ;; - # F+F5 -- toggle vga - 0000003[012]) - notify - /etc/acpi/actions/vga-toggle.sh - ;; # Fn+F9 -- increase volume 00000015) - amixer -q set $VOLUME_LABEL 2+ unmute + amixer -q set $VOLUME_LABEL 4+ unmute amixer -q set $HEADPHONE_LABEL on show_volume ;; # Fn+F3 -- decrease brightness # Fn+F4 -- increase brightness 0000002?) + show_brightness # actual brightness change is handled in hardware ;; + # Fn+F6 -- launch $AP_APP + 00000012) + notify $AP_MSG + $AP_APP + ;; + # (un)plugging AC + 0000005[01]) + show_batt + ;; + # battery low + 00000052) + echo "LOW BATTERY" | aosd_cat -f 0 -u 1500 -o 0 -x 200 -y -300 -n 'DejaVuSans 42' -R 'black' -s 0 -B red -b 255 & + ;; + # F+F5 -- toggle vga + 0000003[012]) + /etc/acpi/actions/vga-toggle.sh + show_vga + ;; + *) + notify $code + ;; esac