-
Notifications
You must be signed in to change notification settings - Fork 0
/
volpm
executable file
·75 lines (69 loc) · 2.54 KB
/
volpm
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
helpFunction()
{
echo ""
echo "Usage: $0 -s [default|mpd] -i/-d [0-9]"
echo -e "\t-s [source] is using pamixer [default] or mpc [mpd] depending on paramater"
echo -e "\t-i [increase] icrease volume by specified number"
echo -e "\t-d [decrease] decrease volume by specified number"
exit 1
}
getIco()
{
if [ $1 -lt 10 ] || [ $1 -eq 10 ]; then
volupico="${HOME}/scripts/icons/volup0.png"
voldownico="${HOME}/scripts/icons/voldown0.png"
elif [ $1 -gt 10 ] && [ $1 -lt 50 ] || [ $1 -eq 50 ]; then
volupico="${HOME}/scripts/icons/volup1.png"
voldownico="${HOME}/scripts/icons/voldown1.png"
elif [ $1 -gt 50 ] && [ $1 -lt 90 ] || [ $1 -eq 90 ]; then
volupico="${HOME}/scripts/icons/volup2.png"
voldownico="${HOME}/scripts/icons/voldown2.png"
elif [ $1 -gt 90 ]; then
volupico="${HOME}/scripts/icons/volup3.png"
voldownico="${HOME}/scripts/icons/voldown3.png"
fi
}
while getopts "s:i:d:" opt
do
case "$opt" in
s ) choosedSource="$OPTARG" ;;
i ) increasedValue="$OPTARG" ;;
d ) decreasedValue="$OPTARG" ;;
? ) helpFunction ;;
esac
done
id="99001" # id of dunst notification
volupico="${HOME}/scripts/volup.png"
voldownico="${HOME}/scripts/voldown.png"
if [ "$choosedSource" == "mpd" ]; then
if [[ -z "$increasedValue" ]] && [[ "$decreasedValue" =~ [0-9] ]]; then
value="-$decreasedValue"
mpc -q volume $value
vol=`mpc -q volume | grep -Po "[0-9]+"`
getIco $vol
dunstify -u low -i $voldownico " Volume" " mpd: $(mpc volume | awk '{print substr($0,8)}' | sed 's/ //g')" -r $id
elif [[ -z "$decreasedValue" ]] && [[ "$increasedValue" =~ [0-9] ]]; then
value="+$increasedValue"
mpc -q volume $value
vol=`mpc -q volume | grep -Po "[0-9]+"`
getIco $vol
dunstify -u low -i $volupico " Volume" " mpd: $(mpc volume | awk '{print substr($0,8)}' | sed 's/ //g')" -r $id
else
helpFunction
fi
else
if [[ -z "$increasedValue" ]] && [[ "$decreasedValue" =~ [0-9] ]]; then
pamixer -d $decreasedValue
vol=`pamixer --get-volume`
getIco $vol
dunstify -u low -i $voldownico " Volume" " sys: $(pamixer --get-volume-human)" -r $id
elif [[ -z "$decreasedValue" ]] && [[ "$increasedValue" =~ [0-9] ]]; then
pamixer -i $increasedValue
vol=`pamixer --get-volume`
getIco $vol
dunstify -u low -i $volupico " Volume" " sys: $(pamixer --get-volume-human)" -r $id
else
helpFunction
fi
fi