diff options
| author | Suleyman Farajli <suleyman@farajli.net> | 2025-10-26 22:23:31 +0400 |
|---|---|---|
| committer | Suleyman Farajli <suleyman@farajli.net> | 2025-10-26 22:23:31 +0400 |
| commit | cb78290f31886fb1f9a5e7c2a764dda55a459e50 (patch) | |
| tree | 72a2df0645405658d8590d4b8d7d87f1e099f596 /scripts/cli/svol | |
| parent | f8d1bfbd0f27e0763cf75fcda58d010e346515ab (diff) | |
chore: split script installation into CLI and GUI sections
Diffstat (limited to 'scripts/cli/svol')
| -rwxr-xr-x | scripts/cli/svol | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/cli/svol b/scripts/cli/svol new file mode 100755 index 0000000..ec60450 --- /dev/null +++ b/scripts/cli/svol @@ -0,0 +1,50 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to change volume +options: + -i [Vol] Increase volume by Vol + -d [Vol] Decrease volume by Vol + -s [Vol] Set volume to Vol + -p Show the current volume + -t Toggle between mute and unmute + -h Print this message and exit +EOF + +exit 0 +} + +check_program "pactl" "pulseaudio must be installed" + +[ $# != 1 ] && [ $# != 2 ] && invalid_use + +while getopts "i:d:s:pth" option; do + case "${option}" in + i) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ +${OPTARG}%" ;; + + d) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ -${OPTARG}%" ;; + + s) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ ${OPTARG}%" ;; + + t) run --reload-status "pactl set-sink-mute @DEFAULT_SINK@ toggle" ;; + + p) + if ! pactl get-sink-volume @DEFAULT_SINK@ \ + | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' | head -n1 2>/dev/null; then + err "Failed to get current volume" + else + exit 0 + fi + ;; + h) help ;; + + *) invalid_use -h ;; + + esac +done + +# Unreachable +invalid_use |
