Advertisement
Guest User

i3blocks volume script

a guest
Jul 8th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. ################################
  4. # Shows info about sound/volume.
  5. #
  6. # Dependencies:
  7. # - pulseaudio-ctl
  8. #
  9. ################################
  10.  
  11. full_audio_status=$(pulseaudio-ctl full-status)
  12. # Create an array which contains the volume in the first part and the mute state in the second part
  13. array_audio=($full_audio_status)
  14.  
  15. vol=${array_audio[0]}
  16.  
  17. # Set the mute status and the color
  18. if [ ${array_audio[1]} = "yes" ]; then
  19. is_muted=true
  20. color="#FF0000"
  21. else
  22. is_muted=false
  23. color="#FFFFFF"
  24. fi
  25.  
  26. # Determine icon
  27. if [ $vol -eq 0 ] || $is_muted; then
  28. icon=""
  29. else
  30. if [ $vol -le 33 ]; then
  31. icon=""
  32. else
  33. icon=""
  34. fi
  35. fi
  36.  
  37. echo $icon $vol"%" # full text
  38. echo $icon $vol"%" # short text
  39. echo $color
  40. exit 0 # status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement