Showing posts with label volume. Show all posts
Showing posts with label volume. Show all posts

Friday, December 31, 2010

volume keys in lxde

gmixer is just not working for me correctly under the Fedora LXDE spins on my Asus EEE laptop. So I hacked together a solution using some suggestions I found across the 'net.

add to the "keyboard" section in ~/.config/openbox/lxde-rc.xml

<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>/home/user/bin/vol.sh down</command>
</action>
</keybind>
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>/home/user/bin/vol.sh up</command>
</action>
</keybind>
<keybind key="XF86AudioMute">
<action name="Execute">
<command>/home/user/bin/vol.sh mute</command>
</action>
</keybind>


/home/user/bin/vol.sh

#!/bin/bash

function dispvolpercentage() {
zenity --progress --text="Volume" --percentage="$1" --no-cancel --timeout=1
}

function getvolume() {
amixer get Master | grep -o -E "[0-9]+%" | head -1 | cut -d '%' -f 1
}

case "$1" in
up)
VAL="`getvolume`"
VAL=$(($VAL+5))
amixer set Master ${VAL}%
dispvolpercentage $VAL
;;
down)
VAL="`getvolume`"
VAL=$(($VAL-5))
amixer set Master ${VAL}%
dispvolpercentage $VAL
;;
mute)
amixer set Master toggle
;;
esac


References
* http://wiki.lxde.org/en/LXDE:Questions#How_do_I_make_my_keyboard_volume_buttons_work.3F
* https://bbs.archlinux.org/viewtopic.php?id=69589&p=1 - I wrote my script based on this one but just using zenity (doesn't look very nice, but works)