#!/bin/ash
#191003 sfs
set Master on
[ "`basename $0`" = volup ] && z=+ || z=-
amixer set Master 5%$z
#percent=`amixer sget Master |grep % |cut -f2 -d\[ |cut -f1 -d\]|head -n 1| tr -d "%" `
a="`amixer get Master | sed -n '/%/{s/^.*\[\([0-9]\+\)%\].*$/\1/p;q}'`"
i=/usr/share/pixmaps/speaker_
if 	[ $a -gt 66 ] ;then i=${i}3.svg
elif 	[ $a -gt 33 ] ;then i=${i}2.svg
else i=${i}1.svg
fi
notify-send -i $i --expire-time=1000  "Громкость $a%" &
exit


K(){ kill  `pgrep -f "yad --title=vol"`;}
K
yad --title=vol --image="/usr/share/pixmaps/sound.svg"  --undecorated \
--no-buttons --geometry=-0 --progress --percentage="$percent" \
--timeout 2 --skip-taskbar --wrap --text "<b>
   Громкость звука</b>" \
--progress-text="$percent %" &
sleep 2 && K
killall xbindkeys
xbindkeys &
