redid volume & some refactoring
This commit is contained in:
parent
18a1ff2f2e
commit
b0c590080c
4 changed files with 120 additions and 63 deletions
34
sway/chvol.sh
Executable file
34
sway/chvol.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
max=100
|
||||
|
||||
if [ $1 = 'source' ]; then
|
||||
object="@DEFAULT_AUDIO_SOURCE@"
|
||||
elif [ $1 = 'sink' ]; then
|
||||
object="@DEFAULT_AUDIO_SINK@"
|
||||
else
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
if [ $2 = 'mute' ]; then
|
||||
wpctl set-mute $object toggle
|
||||
exit 0
|
||||
fi;
|
||||
|
||||
val=$(wpctl get-volume $object | awk '{print $2}')
|
||||
val=$(( (100*${val%%.*}) + ${val#*.} ))
|
||||
val=$(( $val + $2 ))
|
||||
|
||||
if [ $val -gt $max ]; then
|
||||
val=$max
|
||||
elif [ $val -lt 0 ]; then
|
||||
val=0
|
||||
fi;
|
||||
|
||||
|
||||
|
||||
dec=$(( val / 100 ))
|
||||
frac=$(( val % 100 ))
|
||||
if [ $frac -lt 10 ]; then
|
||||
frac="0$frac"
|
||||
fi
|
||||
|
||||
wpctl set-volume $object "$dec.$frac"
|
||||
Loading…
Add table
Add a link
Reference in a new issue