-
Notifications
You must be signed in to change notification settings - Fork 14
/
kano-volume
executable file
·52 lines (43 loc) · 1.67 KB
/
kano-volume
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# kano-volume
#
# Copyright (C) 2014,2015 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
#
# This script increases and decreases the analog audio volume output level
#
# TODO: How to increase/decrease volume for HDMI output?
#
# Check whether omxplayer is running, if not, we don't need to send
# any messages on Dbus
pgrep 'omxplayer' > /dev/null
omx_running="$?"
if [ "$omx_running" -eq 0 ]; then
USER_NAME="$(id -u -n)"
OMXPLAYER_DBUS_ADDR="/tmp/omxplayerdbus.$USER_NAME"
OMXPLAYER_DBUS_PID="/tmp/omxplayerdbus.$USER_NAME.pid"
export DBUS_SESSION_BUS_ADDRESS=`cat $OMXPLAYER_DBUS_ADDR`
export DBUS_SESSION_BUS_PID=`cat $OMXPLAYER_DBUS_PID`
fi
# First parameter is either "up" or "down"
updown=$1
case $updown in
"up")
amixer set Master 1+ > /dev/null 2>&1
dbus-send --session --type=signal --dest=me.kano.audio /me/kano/audio me.kano.audio.volume.changed
if [ "$omx_running" -eq 0 ]; then
dbus-send --print-reply=literal --session --dest=org.mpris.MediaPlayer2.omxplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:18 >/dev/null
fi
;;
"down")
amixer set Master 1- > /dev/null 2>&1
dbus-send --session --type=signal --dest=me.kano.audio /me/kano/audio me.kano.audio.volume.changed
if [ "$omx_running" -eq 0 ]; then
dbus-send --print-reply=literal --session --dest=org.mpris.MediaPlayer2.omxplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:17 >/dev/null
fi
;;
*)
echo "Syntax error: kano-volume < up | down >"
exit -1
esac
exit 0