/
pxf-sound
executable file
·124 lines (98 loc) · 2.99 KB
/
pxf-sound
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# script by Ahau <ahau@porteus.org>
# script to change the volume in Porteus-XFCE
# channel is tied to the selected channel in volumeicon, so this requires retrovol (unless you only want to change Master Volume)
#some user editable variables:
#change to 0 if you don't want gtkdialog gui box
show_gui=1
#change icons...
activeicon=/opt/porteus-scripts/extra/icons/audio-volume-high.svg
muteicon=/opt/porteus-scripts/extra/icons/audio-volume-muted.svg
# This will search the retrovol configs for the specified volume channel
# this file will not exist unless the user reconfigures retrovol, so it defaults to Master Playback Volume
# if ~/retrovolrc is not found.
virc=~/.config/volumeicon/volumeicon
if [ -e $virc ]; then
step=`grep stepsize $virc |cut -d '=' -f2`
vol_channel=`grep ^channel= $virc | cut -d '=' -f2`
fi
[ ! $step ] && step=5
[ ! $vol_channel ] && vol_channel='Master'
export vol_channel
export step
if [ "$1" = "up" ]; then
amixer set $vol_channel $step%+
fi
if [ "$1" = "down" ]; then
amixer set $vol_channel $step%-
fi
if [ "$1" = "toggle" ]; then
amixer set $vol_channel toggle
fi
# the rest will only be executed if the user wants to show the gtkdialog volume box
if [ "$show_gui" = "1" ]; then
vol_level=`amixer get $vol_channel|tail -n1| sed -r 's/.*\[(.*)%\].*/\1/'`
echo $vol_level > /tmp/.pxf-volume
unset sound_off
sound_off=`amixer get $vol_channel|tail -n1| grep '\[off\]'`
if [ "$sound_off" ]; then
mute=\(muted\)
vicon=$muteicon
export mute
else
vicon=$activeicon
fi
export vicon
find_level (){
vol_level=`amixer get $vol_channel|tail -n1| sed -r 's/.*\[(.*)%\].*/\1/'`
export vol_level
}
export PXF_DIALOG='
<window accept_focus="false" decorated="false" skip_taskbar_hint="true" window_position="1">
<hbox>
<pixmap> <width>24</width><height>24</height>
<input file>'$vicon'</input>
</pixmap>
<progressbar>
<label>Volume '`echo $mute`'</label>
<input>while [ "$M" != "100" ]; do M=`cat /tmp/.pxf-volume`; echo $M; sleep .125; done;</input>
<action type="exit">Ready</action>
</progressbar>
</hbox>
</window>
'
show_volume (){
p=0
gtkdialog --program=PXF_DIALOG &
while [ "$p" -lt "12" ]; do
vol_status=`amixer get $vol_channel|tail -n1`
find_level
if [ "$vol_level" = 100 ]; then
vol_level=99.5
fi
if [ "$vol_status" != "$vol_check" ]; then
p=0
fi
echo $vol_level > /tmp/.pxf-volume
vol_check=$vol_status
sleep .125
p=$(( p + 1 ));
done
echo 100 > /tmp/.pxf-volume
}
if [ "$1" = "toggle" ]; then
old_pid=`ps aux |grep PXF_DIALOG |grep -v grep|cut -d ' ' -f6,7|sed 's/ //g'`
[ "$old_pid" ] && kill $old_pid
show_volume
fi
if [ "$1" = "up" ]; then
if [ ! `ps aux | grep -v grep |grep PXF_DIALOG` ]; then
show_volume
fi
fi
if [ "$1" = "down" ]; then
if [ ! `ps aux | grep -v grep |grep PXF_DIALOG` ]; then
show_volume
fi
fi
fi