sway: structure scripts, add helpers in separate file
This commit is contained in:
parent
307d1dd03d
commit
9a4b96932a
5 changed files with 86 additions and 70 deletions
30
bin/volume
30
bin/volume
|
@ -1,13 +1,9 @@
|
|||
#!/bin/bash
|
||||
sink=$(pacmd list-sinks | grep "* index" | grep -oE '[0-9]*')
|
||||
cmd=""
|
||||
app="pavucontrol"
|
||||
|
||||
if [ -z "$sink" ]; then
|
||||
echo "ERROR: invalid sink: \"$sink\""
|
||||
exit 1
|
||||
fi
|
||||
source $HOME/.config/sway/bin/helpers
|
||||
SINK=$(pacmd list-sinks | grep "* index" | grep -oE '[0-9]*')
|
||||
APP="pavucontrol"
|
||||
|
||||
## helpers
|
||||
function _toggle() {
|
||||
a=$1
|
||||
if [ $(pgrep $a) ]; then
|
||||
|
@ -17,20 +13,28 @@ function _toggle() {
|
|||
fi
|
||||
}
|
||||
|
||||
## main
|
||||
if [ -z "$SINK" ]; then
|
||||
_log VOLUME ERROR args: $*
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
d*)
|
||||
pactl set-sink-volume $sink -5%
|
||||
pactl set-sink-volume $SINK -5%
|
||||
;;
|
||||
i*)
|
||||
pactl set-sink-volume $sink +5%
|
||||
pactl set-sink-volume $SINK +5%
|
||||
;;
|
||||
m*)
|
||||
pactl set-sink-mute $sink toggle
|
||||
pactl set-sink-mute $SINK toggle
|
||||
;;
|
||||
gui)
|
||||
_toggle $app
|
||||
_check_app $APP
|
||||
_toggle $APP
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid command: \"$1\""
|
||||
echo "invalid command: \"$1\""
|
||||
echo "arguments: [decrease|increase|mute|gui]"
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue