it uses amixer to change the volume and yaf-splash to display the status
here's how it looks
here's the script
Code: Select all
#! /bin/bash
if [[ $1 -eq 1 ]]
then
P=`amixer sset 'Master Front' 1+ | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/Master Front: /g' | sed 's/\]//g'`
M=`amixer sset 'PCM' 2+ | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/PCM: /g' | sed 's/\]//g'`
yaf-splash -text "$P $M" -timeout 1
else if [[ $1 -eq 2 ]]
then
P=`amixer sset 'Master Front' 1- | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/Master Front: /g' | sed 's/\]//g'`
M=`amixer sset 'PCM' 2- | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/PCM: /g' | sed 's/\]//g'`
yaf-splash -text "$P $M" -timeout 1
else if [[ $1 -eq 3 ]]
then
P=`amixer sset 'Master Front',0 toggle | grep "Front Left:" | awk '{print $7}'`
if [[ ''$P'' == '[off]' ]]
then
P="Volume is off"
else
P="Volume is on"
fi
yaf-splash -text "$P" -timeout 1
fi
fi
fi
not all cards have the same channels so you might want to check which controls change the volume by running alsamixer in a terminal and messing around there for a while, then make the changes in the script
after you're done changing what's relevant you your sound card save the script somewhere in /usr/bin and chmod +x it. mine is called ali-vol
now to bind that to the keyboad.
assuming you are running openbox go to your ~/.config/openbox/rc.xml
and in the keyboard bindings add
Code: Select all
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>ali-vol 1</command>
</action>
</keybind>
<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>ali-vol 2</command>
</action>
</keybind>
<keybind key="XF86AudioMute">
<action name="Execute">
<command>ali-vol 3</command>
</action>
</keybind>
Code: Select all
<keybind key="C-A-S-Up">
<action name="Execute">
<command>ali-vol 1</command>
</action>
</keybind>
<keybind key="C-A-S-Down">
<action name="Execute">
<command>ali-vol 2</command>
</action>
</keybind>
<keybind key="C-A-S-Left">
<action name="Execute">
<command>ali-vol 3</command>
</action>
</keybind>
<keybind key="C-A-S-Right">
<action name="Execute">
<command>ali-vol 3</command>
</action>
</keybind>
Code: Select all
openbox --reconfigure
if anyone manages to get the media keys working please let me know