volume.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. ## Author : Aditya Shakya
  3. ## Mail : adi1090x@gmail.com
  4. ## Github : @adi1090x
  5. ## Twitter : @adi1090x
  6. style="$($HOME/.config/rofi/applets/menu/style.sh)"
  7. dir="$HOME/.config/rofi/applets/menu/configs/$style"
  8. rofi_command="rofi -theme $dir/volume.rasi"
  9. ## Get Volume
  10. #VOLUME=$(amixer get Master | tail -n 1 | awk -F ' ' '{print $5}' | tr -d '[]%')
  11. MUTE=$(amixer get Master | tail -n 1 | awk -F ' ' '{print $6}' | tr -d '[]%')
  12. active=""
  13. urgent=""
  14. if [[ $MUTE == *"off"* ]]; then
  15. active="-a 1"
  16. else
  17. urgent="-u 1"
  18. fi
  19. if [[ $MUTE == *"off"* ]]; then
  20. active="-a 1"
  21. else
  22. urgent="-u 1"
  23. fi
  24. if [[ $MUTE == *"on"* ]]; then
  25. VOLUME="$(amixer get Master | tail -n 1 | awk -F ' ' '{print $5}' | tr -d '[]%')%"
  26. else
  27. VOLUME="Mute"
  28. fi
  29. ## Icons
  30. ICON_UP=""
  31. ICON_DOWN=""
  32. ICON_MUTED=""
  33. options="$ICON_UP\n$ICON_MUTED\n$ICON_DOWN"
  34. ## Main
  35. chosen="$(echo -e "$options" | $rofi_command -p "$VOLUME" -dmenu $active $urgent -selected-row 0)"
  36. case $chosen in
  37. $ICON_UP)
  38. amixer -Mq set Master,0 5%+ unmute && notify-send -u low -t 1500 "Volume Up $ICON_UP"
  39. ;;
  40. $ICON_DOWN)
  41. amixer -Mq set Master,0 5%- unmute && notify-send -u low -t 1500 "Volume Down $ICON_DOWN"
  42. ;;
  43. $ICON_MUTED)
  44. amixer -q set Master toggle
  45. ;;
  46. esac