birdwm

birdwm - mrgrouse's daily driver fork of suckless' dwm. Contains many patches and is currently loosely maintained.
Log | Files | Refs | README | LICENSE

volume.sh (2555B)


      1 #!/bin/bash
      2 # 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>.
      3 # volume down icon is from "https://www.flaticon.com/free-icons/volume-down" title="volume down icons">Volume down icons created by Freepik - Flaticon
      4 # 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>.
      5 # Credit from https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a & https://wiki.archlinux.org/title/Dunst  .
      6 
      7 # You can call this script like this:
      8 # $./volume.sh up
      9 # $./volume.sh down
     10 # $./volume.sh mute
     11 
     12 function get_volume {
     13   #pamixer --get-volume
     14   wpctl get-volume @DEFAULT_AUDIO_SINK@
     15 }
     16 
     17 #function is_mute {
     18 #    amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
     19 #}
     20 
     21 function send_notification {
     22     volume=`get_volume`
     23     # Make the bar with the special character ─ (it's not dash -)
     24     # https://en.wikipedia.org/wiki/Box-drawing_character
     25     bar=$(seq -s "─" $(($volume / 2)) | sed 's/[0-9]//g')
     26     # Send the notification
     27     #dunstify -i $HOME/Pictures/sysicon/volume-up.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "Volume: ${volume}%"
     28     dunstify -i $HOME/Pictures/sysicon/volume-up.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "${volume}%"
     29     #notify-send "volume: $volume%"
     30 }
     31 
     32 function send_notification1 {
     33     volume=`get_volume`
     34     # Make the bar with the special character ─ (it's not dash -)
     35     # https://en.wikipedia.org/wiki/Box-drawing_character
     36     bar=$(seq -s "─" $(($volume / 2)) | sed 's/[0-9]//g')
     37     # Send the notification
     38     dunstify -i $HOME/Pictures/sysicon/volume-down.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "${volume}%"
     39     #notify-send "volume: $volume%"
     40 }
     41 case $1 in
     42     get) 
     43 	get_volume
     44 	send_notification
     45 	;;
     46     up)
     47 	# Set the volume on (if it was muted)
     48 	#amixer -D pulse set Master on > /dev/null
     49 	# Up the volume (+ 1%)
     50 	#amixer -D pulse sset Master 1%+ > /dev/null
     51 	
     52 	# new version for pulseaudio
     53 	pactl set-sink-volume @DEFAULT_SINK@ +1%
     54 	send_notification
     55 	;;
     56     down)
     57 	# new version for pulseaudio
     58 	pactl set-sink-volume @DEFAULT_SINK@ -1%
     59 	send_notification1
     60 	;;
     61     mute)
     62     	# Toggle mute
     63 #	amixer -D pulse set Master 1+ toggle > /dev/null
     64 #	if is_mute ; then
     65 #        dunstify -i $HOME/Pictures/sysicon/volume-mute.png -t 8000 -r 2593 -u normal "Volume: Mute"
     66 #    else
     67 	pactl set-sink-mute @DEFAULT_SINK@ toggle
     68         send_notification
     69 #	fi
     70 	;;
     71 esac