commit 045cc36a07ccdae60de3a8b86c1b1ddefd212053 parent 96b7faa5a0b79a6819e3d8f0b006c76e998bc9a7 Author: grouse <bdmfegys@duck.com> Date: Sat, 17 Feb 2024 19:07:37 -0500 add volume script to extras Diffstat:
| A | extras/volume.sh | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 63 insertions(+), 0 deletions(-)
diff --git a/extras/volume.sh b/extras/volume.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# volume up icon is from <a href="https://www.flaticon.com/free-icons/volume-up" title="volume up icons">Volume up icons created by Freepik - Flaticon</a>. +# volume down icon is from "https://www.flaticon.com/free-icons/volume-down" title="volume down icons">Volume down icons created by Freepik - Flaticon +# volume mute icon is from <a href="https://www.flaticon.com/free-icons/ui" title="ui icons">Ui icons created by Icon Hubs - Flaticon</a>. +# Credit from https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a & https://wiki.archlinux.org/title/Dunst . + +# You can call this script like this: +# $./volume.sh up +# $./volume.sh down +# $./volume.sh mute + +function get_volume { + /usr/local/bin/getvolume get_volume +} + +#function is_mute { +# amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null +#} + +function send_notification { + volume=`get_volume` + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character + bar=$(seq -s "─" $(($volume / 2)) | sed 's/[0-9]//g') + # Send the notification + dunstify -i $HOME/Pictures/sysicon/volume-up.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "Volume: ${volume}%" +} + +function send_notification1 { + volume=`get_volume` + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character + bar=$(seq -s "─" $(($volume / 2)) | sed 's/[0-9]//g') + # Send the notification + dunstify -i $HOME/Pictures/sysicon/volume-down.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "Volume: ${volume}%" +} +case $1 in + up) + # Set the volume on (if it was muted) + #amixer -D pulse set Master on > /dev/null + # Up the volume (+ 1%) + #amixer -D pulse sset Master 1%+ > /dev/null + + # new version for pulseaudio + pactl set-sink-volume @DEFAULT_SINK@ +1% + send_notification + ;; + down) + # new version for pulseaudio + pactl set-sink-volume @DEFAULT_SINK@ -1% + send_notification1 + ;; + mute) + # Toggle mute +# amixer -D pulse set Master 1+ toggle > /dev/null +# if is_mute ; then +# dunstify -i $HOME/Pictures/sysicon/volume-mute.png -t 8000 -r 2593 -u normal "Volume: Mute" +# else + pactl set-sink-mute @DEFAULT_SINK@ toggle + send_notification +# fi + ;; +esac