*nohtml*

local/bin/volume

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