Guest User

volume notification script

a guest
Sep 4th, 2011
304
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #DESKTOP=:0 # need for notifications run 'over' display
  4. mixer_state=$(amixer get Master | awk '$1=="Mono:" {print $6}')
  5. x=$(amixer get Master | sed -rn "/[^[]+\[/{s///;s/%.+//p;q}")
  6. z=$[x/10];  y='◼◼◼◼◼◼◼◼◼◼'
  7. zz=$[10-z];yy='◻◻◻◻◻◻◻◻◻◻'
  8.  
  9. # get current screen resoultion
  10. curres=$(xdpyinfo | grep dimensions | awk '{print $2}')
  11. # calculate current max x
  12. curmx=$(echo $curres | sed 's/x.*$//')
  13. # calculate current max y
  14. curmy=$(echo $curres | sed 's/^.*x//')
  15.  
  16. poffset=0
  17.  
  18. notify_title="Volume"
  19.  
  20. case $x in
  21.     0*|?|1?)  notify_icon="notification-audio-volume-off";;
  22.     2?|3?|4?)  notify_icon="notification-audio-volume-low";;
  23.     5?|6?|7?)  notify_icon="notification-audio-volume-medium";;
  24.     8?|9?|100)  notify_icon="notification-audio-volume-high";;
  25. esac
  26.  
  27. if [ $mixer_state == "[off]" ];then
  28.     notify_icon="notification-audio-volume-muted"
  29.     notify_title="$notify_title muted"
  30. fi
  31.  
  32. notify-send -i $notify_icon -t 1500 -u low -h int:x:$[$curmx-$poffset] -h \
  33.     int:y:$[$curmy-$poffset] "$notify_title" "${y::z}${yy::zz} $x%"
RAW Paste Data