From 5c916d69d457101326803eb076a746060e3618cf Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Thu, 21 Nov 2024 13:30:52 +0530 Subject: Moved from github --- .local/bin/desktop/volctl | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 .local/bin/desktop/volctl (limited to '.local/bin/desktop/volctl') diff --git a/.local/bin/desktop/volctl b/.local/bin/desktop/volctl new file mode 100755 index 0000000..7d0edb9 --- /dev/null +++ b/.local/bin/desktop/volctl @@ -0,0 +1,50 @@ +#!/bin/sh + +help() { echo "volctl - change system volume +USAGE: volctl "; } + +[ "$#" -lt 1 ] && help >&2 && exit 1 + +case "$1" in + toggle) wpctl set-mute @DEFAULT_SINK@ toggle ;; + up) wpctl set-volume @DEFAULT_SINK@ 5%+ ;; + down) wpctl set-volume @DEFAULT_SINK@ 5%- ;; + *) help >&2; exit 1 ;; +esac + +vol="$(wpctl get-volume @DEFAULT_SINK@ | tr -d .)" +vol="${vol#Volume: }" + +notify() { + if [ -n "$DISPLAY" ]; then + notify-send -t 3000 -r 93475 "$1" + else + printf 'volume : ' + wpctl get-volume @DEFAULT_SINK@ + fi +} + +if [ "$vol" != "${vol% \[MUTED\]}" ]; then + vol="${vol% \[MUTED\]}" + muted=1 +else + muted=0 +fi + +vol="$(printf '%.0f' "$vol")" + +msg="" +if [ "$vol" -gt "100" ]; then icon="📢"; msg=" Boosted" +elif [ "$vol" = "100" ]; then icon="🔊"; msg=" Maxed" +elif [ "$vol" -gt "70" ]; then icon="🔊" +elif [ "$vol" -gt "30" ]; then icon="🔉" +elif [ "$vol" -gt "0" ]; then icon="🔈" +else icon="🔇" +fi + +if [ "$muted" -eq 1 ]; then + notify "🔇 Volume Muted ($vol%)" +else + notify "$icon Volume$msg: $vol%" +fi + -- cgit v1.2.3