summaryrefslogtreecommitdiff
path: root/scripts/svol
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/svol')
-rwxr-xr-xscripts/svol61
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/svol b/scripts/svol
new file mode 100755
index 0000000..f973773
--- /dev/null
+++ b/scripts/svol
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+err() {
+ printf "${1} \n"
+ exit 1
+}
+
+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
+}
+
+if [ $# != 1 ] && [ $# != 2 ]; then
+ err "${0}: Invalid usage\nTry \'$0 -h\' for help."
+fi
+
+while getopts "i:d:s:pth" option; do
+ case "${option}" in
+ i)
+ pactl set-sink-volume @DEFAULT_SINK@ +"${OPTARG}"% \
+ > /dev/null 2>&1 && exit 0 \
+ || err "${0}: Failed to increase"
+ ;;
+ d)
+ pactl set-sink-volume @DEFAULT_SINK@ -"${OPTARG}"% \
+ > /dev/null 2>&1 && exit 0 \
+ || err "${0}: Failed to decrease"
+ ;;
+ s)
+ pactl set-sink-volume @DEFAULT_SINK@ "${OPTARG}"% \
+ > /dev/null 2>&1 && exit 0 \
+ || err "${0}: Failed to set"
+ ;;
+ p)
+ pactl get-sink-volume @DEFAULT_SINK@ 2>/dev/null\
+ || err "${0}: Failed"
+ ;;
+ t)
+ pactl set-sink-volume @DEFAULT_SINK@ toggle \
+ > /dev/null 2>&1 && exit 0 \
+ || err "${0}: Failed to toggle"
+ ;;
+ h)
+ help
+ exit 0
+ ;;
+ *)
+ err "Try \'${0} -h\' for help"
+ ;;
+
+ esac
+done