diff --git a/bin/sway_volume b/bin/sway_volume index 1ee8564..919f800 100755 --- a/bin/sway_volume +++ b/bin/sway_volume @@ -3,6 +3,9 @@ source $HOME/.config/sway/bin/sway_helpers SINK=$(pactl info | grep "Default Sink" | cut -d ' ' -f 3) ICON_PATH=$HOME/.local/share/icons/Tela-circle-dark/16/actions NOTIFY_APP="dunstify -a volume -h string:x-dunst-stack-tag:volume" +VOL1="" +VOL2="" + function getProgressString() { ITEMS="$1" # The total number of items(the width of the bar) @@ -27,7 +30,6 @@ function notify() { ICON="" TITLE="" - M="" if [ "$MUTE" = "yes" ]; then ICON=$ICON_PATH/audio-volume-muted.svg TITLE="${VOLUME}%" @@ -43,7 +45,7 @@ function notify() { TITLE="${VOLUME}%" fi # $NOTIFY_APP -i $ICON -a "Volume" "$TEXT" - $NOTIFY_APP -i $ICON "$TITLE" "[$(getProgressString 15 "$M" " " $VOLUME)]" + $NOTIFY_APP -i $ICON "$TITLE" "$(getProgressString 10 "$VOL1" "$VOL2" $VOLUME)" } APP="pavucontrol" @@ -72,7 +74,12 @@ case $1 in notify ;; i*) - pactl set-sink-volume $SINK +5% + VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//') + INC=$((100 - $VOLUME)) + if [ $INC -gt 5 ]; then + INC=5 + fi + pactl set-sink-volume $SINK +${INC}% paplay $SOUND & notify ;;