#!/bin/sh ### Usage ### -r or --raise to raise the voulmn by 5% ### -l or --lower to lower the voulmn by 5% ### -t or --toggle to toggle mute and unmute # notify osd expire time delay in ms expireTimeNotifyOSD=3000 currentId=1 tmpFile=/tmp/currentVolumnNotifyId$(whoami) # gets the current notify id from our tmp file if [ -s $tmpFile ] then currentId=$(cat $tmpFile) fi # execute amixer action based on param if [ $1 == '--raise' ] || [ $1 == '-r' ] then amixer -D pulse sset Master 5%+ noToggle=true elif [ $1 == '--lower' ] || [ $1 == '-l' ] then amixer -D pulse sset Master 5%- noToggle=true elif [ $1 == '--toggle' ] || [ $1 == '-t' ] then amixer -D pulse set Master 1+ toggle fi currentVolumn=$(amixer -D pulse get Master | egrep -o '[0-9]{1,3}' | tail -n 1) volumnIsMuted=$(amixer -D pulse get Master | egrep -o 'off' | tail -n 1) # get icon based on current volumn if [ $volumnIsMuted ] then icon=audio-volume-muted else icon=audio-volume-low if [ $currentVolumn -gt 60 ] then icon=audio-volume-high elif [ $currentVolumn -gt 30 ] then icon=audio-volume-medium fi fi # execute the notify-send command if [ $noToggle ] then notify-send "Volume" -p -t $expireTimeNotifyOSD -r $currentId -i $icon -h int:value:$currentVolumn > $tmpFile else if [ $volumnIsMuted ] then notify-send "Volume muted" -p -t $expireTimeNotifyOSD -r $currentId -i $icon -h int:value:0 > $tmpFile else notify-send "Volume unmuted" -p -t $expireTimeNotifyOSD -r $currentId -i $icon -h int:value:$currentVolumn > $tmpFile fi fi