[download]

local/bin/volume

   1 #!/bin/bash
   2 
   3 f=~/.cache/volume
   4 source ~/.theme/colors.sh
   5 
   6     set=${1:-0+}
   7 [[ $set == +*    ]] && set="unmute ${set:1}+"
   8 [[ $set == -*    ]] && set="unmute ${set:1}-"
   9 [[ $set ==  mute ]] && amixer get Master | grep -q off && set=unmute
  10 
  11 get=$(amixer get Master      | grep -om 1 '[0-9]*%')
  12 set=$(amixer set Master $set | grep -om 1 '[0-9]*%' | tee $f)
  13 [[ $get != $set ]] && canberra-gtk-play -i dialog-information &
  14 
  15    volume=${set%%%}   icon=婢 color=$foreground
  16 (( volume >=  1 )) && icon=奄
  17 (( volume >= 35 )) && icon=奔
  18 (( volume >= 70 )) && icon=墳
  19 
  20 amixer get Master | grep -q off && icon=婢 color=$color8
  21 
  22 echo $icon > $f.ico
  23 printf '<svg width="22" height="22"><text font-family="Nerdfont"
  24 y="19" font-size="22" fill="%s">%s</text></svg>' $color $icon > $f.svg
  25 
  26 notify-send -a volume -i $f.svg -- "$(printf 'Громкость %4s' $set)"