#!/bin/bash # acpi_hotkeys_ASUS_M6842NW # Manfred Tremmel, based on the script of Stefan Seyfried # echo "my script $*"| \ logger # first get helper functions (e.g. DEBUG, load_scheme, ...) . "/usr/lib/powersave/scripts/helper_functions" PATH=/bin:/usr/bin # be paranoid, we're running as root. export PATH ret=0 MYNAME=${0##*/} # basename $0 if [ $# -ne 3 ] ; then # something wicked happened DEBUG "something wicked happened. number of arguments: $#, arguments: '$*'" ERROR exit 1 fi run_on_xserver() { get_x_user su $X_USER -c "export DISPLAY=$DISP;$1" } TYPE=$1 set $3 # powersaved gives us "other ''" so we must split it. EVENT=$1 # "hotkey" ACPI=$2 # "HOTK" WHAT=$3 # "00000052" SERIAL=$4 # "0000001c" # it is easier to deal with numerical values (for me :-) declare -i VAL VAL=0x$WHAT # hex -> decimal echo "VAL: '$VAL'"| \ logger -t $MYNAME if [ "$EVENT" != "hotkey" ]; then echo "non-hotkey-event: $TYPE $EVENT $ACPI $WHAT $SERIAL" | logger -t $MYNAME exit 0 fi if [ $VAL -gt 16 -a $VAL -lt 48 ]; then # brightness up/down exit 0 elif [ $VAL -eq 51 -o $VAL -eq 52 ]; then # LCD on/off exit 0 elif [ $VAL -ge 97 -a $VAL -le 99 ]; then # internal/external/both exit 0 elif [ $VAL -eq 50 ]; then # Fn-F10 -> mute if [ "`run_on_xserver '/opt/kde3/bin/dcop kmix | grep -c -m 1 kmix'`" = "1" ] ; then if [ "`run_on_xserver '/opt/kde3/bin/dcop kmix Mixer0 mute 0'`" = "false" ] ; then run_on_xserver "/opt/kde3/bin/dcop kmix Mixer0 setMute 0 true" & else run_on_xserver "/opt/kde3/bin/dcop kmix Mixer0 setMute 0 false" & fi else mute & # from the aumix package fi : # set loudnes to 0 elif [ $VAL -eq 49 ]; then # Fn-F11 -> volume down if [ "`run_on_xserver '/opt/kde3/bin/dcop kmix | grep -c -m 1 kmix'`" = "1" ] ; then run_on_xserver "/opt/kde3/bin/dcop kmix Mixer0 decreaseVolume 0" & else aumix -w -3 & # needs aumix, does "pcm" fi : # reduce loudnes elif [ $VAL -eq 48 ]; then # Fn-F12 -> volume up if [ "`run_on_xserver '/opt/kde3/bin/dcop kmix | grep -c -m 1 kmix'`" = "1" ] ; then run_on_xserver "/opt/kde3/bin/dcop kmix Mixer0 increaseVolume 0" & else aumix -w +3 & # needs aumix, does "pcm" fi : # increase loudnes elif [ $VAL -eq 64 ]; then # << run_on_xserver "/opt/kde3/bin/dcop kaffeine Kaffeine previous" & : # fast backward elif [ $VAL -eq 65 ]; then # >> run_on_xserver "/opt/kde3/bin/dcop kaffeine Kaffeine next" & : # fast forward elif [ $VAL -eq 67 ]; then # stop if [ "`run_on_xserver '/opt/kde3/bin/dcop kaffeine Kaffeine isPlaying'`" = "true" ] ; then run_on_xserver "/opt/kde3/bin/dcop kaffeine Kaffeine stop" & : # kaffeine is running, press stop else eject /dev/dvdrecorder : # kaffeine is not running, eject CD/DVD fi : # stop elif [ $VAL -eq 69 ]; then # play/pause if [ "`run_on_xserver '/opt/kde3/bin/dcop kaffeine Kaffeine isPlaying'`" = "true" ] ; then run_on_xserver "/opt/kde3/bin/dcop kaffeine Kaffeine togglePlayPause" & : # play button in kaffeine elif [ "`cd-info --no-tracks --no-cddb --no-device-info --no-header 2>/dev/null | grep -c --max-count=1 'Audio CD'`" = "1" ] ; then run_on_xserver "/opt/kde3/bin/kaffeine CD" & : # Audio-CD elif [ "`cd-info --no-tracks --no-cddb --no-device-info --no-header 2>/dev/null | grep -c --max-count=1 'VCD'`" = "1" ] ; then run_on_xserver "/opt/kde3/bin/kaffeine VCD" & : # (S)VCD elif [ "`cd-info --no-tracks --no-cddb --no-device-info --dvd --no-header 2>/dev/null | grep -c --max-count=1 'UDF:'`" = "1" ] ; then run_on_xserver "/opt/kde3/bin/kaffeine DVD" & : # Video-DVD else run_on_xserver "/opt/kde3/bin/kaffeine" & : # nothing special, just start kaffeine fi : # do something elif [ $VAL -eq 80 ]; then # Start Mailer run_on_xserver "/opt/kde3/bin/kmail" & : # do something elif [ $VAL -eq 81 ]; then # Start Browser run_on_xserver "/opt/kde3/bin/kfmclient openProfile webbrowsing" & : # do something elif [ $VAL -eq 93 ]; then # Wireles LAN if [ "`ps -A | grep -c kwifimanager`" = "0" ] ; then run_on_xserver "/opt/kde3/bin/kwifimanager" & else killall kwifimanager fi : # start kwifimanager elif [ $VAL -eq 92 ]; then # Power4 Gear + run_on_xserver "/opt/kde3/bin/ksysguard" & : # start ksysguard else DEBUG "undefined hotkey: $VAL $TYPE $EVENT $ACPI $WHAT $SERIAL" DIAG ret=1 fi exit $ret