small pixel drawing of a pufferfish dotfiles

Add simple volume modification toolset
Jes Olson jolson@digitalocean.com
Thu, 06 Jan 2022 16:57:59 -0600
commit

1ad7687d5cfe02d774c36e4ed2b186b6049303d8

parent

d4e78faa0161c6f1bb7e30136c96a6943e1f24d7

2 files changed, 50 insertions(+), 0 deletions(-)

jump to
M .config/sway/config.config/sway/config

@@ -170,6 +170,10 @@ # respectively.

bindsym $mod+b splith bindsym $mod+v splitv + # volume control, obviously + bindsym $mod+XF86AudioLowerVolume exec vol down 10 + bindsym $mod+XF86AudioRaiseVolume exec vol up 10 + # Switch the current container between different layout styles # bindsym $mod+s layout stacking # bindsym $mod+w layout tabbed
A bin/vol

@@ -0,0 +1,46 @@

+#!/bin/sh -e +# +# simple pulse wrapper for controlling +# audio stuff i care about + +get_current_volume_percent() { + percent="$(pactl get-sink-volume @DEFAULT_SINK@ | awk '/Volume/ {print $5}')" + strip_perc="$(printf "%s" "$percent" | cut -d '%' -f 1)" + printf "%s" "$strip_perc" +} + +notify_current_volume() { + vol="$(get_current_volume_percent)" + if [ "$vol" -gt 100 ]; then + # prevent volumes of >100% for the + # good of all ears + pactl set-sink-volume @DEFAULT_SINK@ 100% + notify-send '🔈 vol' --hint=int:value:100 -t 800 + elif [ "$vol" -lt 0 ]; then + # prevent volumes of <0% for the + # good of all ... dog... whateij fiwjoefj + pactl set-sink-volume @DEFAULT_SINK@ 0% + notify-send '🔈 vol' --hint=int:value:0 -t 800 + else + notify-send '🔈 vol' --hint=int:value:"$vol" -t 800 + fi +} + +case "$1" in + ls|list) pactl list short sinks ;; + set) pactl set-default-sink "$2" ;; + [0-9]*) + pactl set-sink-volume @DEFAULT_SINK@ "$1"% + notify_current_volume + ;; + up) + # expect $2 = % to increase + pactl set-sink-volume @DEFAULT_SINK@ +"$2"% + notify_current_volume + ;; + down) + pactl set-sink-volume @DEFAULT_SINK@ -"$2"% + notify_current_volume + ;; + *) ;; +esac