diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2020-12-15 15:44:53 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2020-12-15 15:44:53 -0500 |
| commit | 619cb6070d87a619f0a9586bb4ff98a4cdfcef67 (patch) | |
| tree | 0cdf7210e939b89f87b6f54cf461daf53d00fdde | |
| parent | c1b7561a7c35b1ee91eac7ae6990bc99590e3453 (diff) | |
| download | dotfiles-619cb6070d87a619f0a9586bb4ff98a4cdfcef67.tar.gz dotfiles-619cb6070d87a619f0a9586bb4ff98a4cdfcef67.tar.xz | |
Add a volume control script
| -rw-r--r-- | bin/Makefile | 1 | ||||
| -rw-r--r-- | bin/volCtl | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bin/Makefile b/bin/Makefile index a66fbff..0189db6 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -14,4 +14,5 @@ install: install night $(HOME)/bin/ install wallpaper $(HOME)/bin/ install status-bar $(HOME)/bin/ + install volCtl $(HOME)/bin/ diff --git a/bin/volCtl b/bin/volCtl new file mode 100644 index 0000000..1071d8c --- /dev/null +++ b/bin/volCtl @@ -0,0 +1,24 @@ +#!/bin/sh +sinkName=$(pacmd info | grep 'Default sink' | awk '{print $4}') +sinkNumber=$(pacmd info | grep "sink:.*$sinkName" | awk '{print $2}') + +getVolume() { + volumeInput=$(pactl list sinks) + currentVolume=$(echo "${volumeInput#*Sink #$sinkNumber}" | grep -E 'V.*-left' | grep -oE '[0-9]+%' | tail -n 1) + notify-send "Volume: $currentVolume" +} + +case "$1" in + up) pactl set-sink-volume @DEFAULT_SINK@ +5%; getVolume;; + down) pactl set-sink-volume @DEFAULT_SINK@ -5%; getVolume;; + mute) muted=$(pactl list sinks | grep 'Mute: yes') + if [ -z "$muted" ]; then + pactl set-sink-mute @DEFAULT_SINK@ 1 + notify-send Volume: Muted + else + pactl set-sink-mute @DEFAULT_SINK@ 0 + getVolume + fi;; + *) echo error;; +esac + |
