2012-03-17, 13:50
This was born due to a lack to control volume when launching external program from within xbmc. The external program uses the alsa master volume and not the internal xbmc volume and if you have an xbmc appliance and you controls it just with a remote, this is a problem.
Prerequisite: aosd-cat and lirc
for ubuntu systems.
The bash script:
eventually made changes to fit your needs, save it into a new change_volume.sh file and make it executable:
To check that everything is going well, test the script with:
You should hear the sound lower down and its value on the screen (a very small and elegant bottom left corner green value).
Now edit your .lircrc and put this at bottom:
Where I've placed the change_volume.sh script into ~/.xbmc/system/ folder and mapped the actions to the lirc buttons KEY_ZOOM (volume up) and KEY_MEDIA (volume down).
Finally start irexec ad daemon:
to run the change_volume.sh script when the remote control buttons are pressed.
If you wants irexec at boot time, put this line inat the end of the /etc/rc.local file:
Hope this can be useful for someone.
Prerequisite: aosd-cat and lirc
Code:
$ sudo apt-get install aosd-cat
$ sudo apt-get install lirc
for ubuntu systems.
The bash script:
Code:
#!/bin/bash
# parameter: <value>- or <value>+ or <value>
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die -e "\n1 argument required, $# provided.\n\nUsage:\n$0 1+ # increase alsa Master volume by 1 unit\n$0 2dB+ # increase alsa Master volume by 2 dB\n$0 10- # decrease alsa Master volume by 10 units\n$0 50 # set alsa Master volume to 50\n"
u=1000
o=350
e=1
R=green
b=0
B=black
DISPLAY=:0.0 # primary display
AMIXER_CMD=/usr/bin/amixer
KILL_CMD=/usr/bin/killall
$AMIXER_CMD -q -c 0 sset Master,0 $1 2>/dev/null
$KILL_CMD aosd_cat &> /dev/null
CURR_VOLUME=`$AMIXER_CMD get Master 2>/dev/null | grep 'Mono:' | sed -e 's/^[^\[]*//' -e 's/^.//' -e 's/%.*$//'`
if [ "$CURR_VOLUME" != "0" ]
then
echo $CURR_VOLUME |DISPLAY=$DISPLAY aosd_cat -n "Arial Black 18" -u $u -o $o -R $R -S none -f 0 -y -10 -e $e -b $b -B $B -t 0 -d 5 &
else
echo "Mute" |DISPLAY=$DISPLAY aosd_cat -n "Arial Black 18" -u $u -o $o -R red -S none -f 0 -y -10 -e $e -b $b -B $B -d 5 -t 0&
fi
eventually made changes to fit your needs, save it into a new change_volume.sh file and make it executable:
Code:
$ chmod ugo+x ./change_volume.sh
To check that everything is going well, test the script with:
Code:
$ ./change_volume 10-
You should hear the sound lower down and its value on the screen (a very small and elegant bottom left corner green value).
Now edit your .lircrc and put this at bottom:
Code:
begin
prog = irexec
remote=devinput
button = KEY_ZOOM
config = ~/.xbmc/system/change_volume.sh 1+
repeat = 1
end
begin
prog = irexec
remote=devinput
button = KEY_MEDIA
config = ~/.xbmc/system/change_volume.sh 1-
repeat = 1
end
Where I've placed the change_volume.sh script into ~/.xbmc/system/ folder and mapped the actions to the lirc buttons KEY_ZOOM (volume up) and KEY_MEDIA (volume down).
Finally start irexec ad daemon:
Code:
$ irexec -d
to run the change_volume.sh script when the remote control buttons are pressed.
If you wants irexec at boot time, put this line inat the end of the /etc/rc.local file:
Code:
su xbmc -c "irexec -d > /dev/null 2>&1"
Hope this can be useful for someone.