Advertisement
Guest User

i3block volume blocklet

a guest
Oct 27th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # return volume percentage
  4. # and rely on volume script to adjust volume on all sinks
  5.  
  6. # normally stored in /usr/share/i3blocks
  7.  
  8. case $BLOCK_BUTTON in
  9.     1) i3 "[instance=pavucontrol] scratchpad show; move position center" >> /dev/null ;; # show pavucontrol
  10.     # 2) ;; # middle click
  11.     3) volume mute ;; # mute volume
  12.     4) volume +5% ;; # scroll up, increase
  13.     5) volume -5% ;; # scroll down, decrease
  14. esac
  15.  
  16. INFO=$(pactl list sinks)
  17. MUTE_STATUS=$(echo "$INFO" | grep "Mute" | head -1 | grep "yes") # nonempty string if mute
  18. VOLUME=$(echo "$INFO" | grep 'Volume' | head -1 | grep -oh '...%' | head -1)
  19.  
  20. if [[ -z "$MUTE_STATUS" ]]; then # if empty string --> not muted
  21.     echo "$VOLUME"
  22.     exit 0
  23. fi
  24.  
  25. echo "MUTE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement