Skip to content

Instantly share code, notes, and snippets.

@tjb0607
Created February 4, 2015 01:58
Show Gist options
  • Select an option

  • Save tjb0607/037cb11817fa372c1947 to your computer and use it in GitHub Desktop.

Select an option

Save tjb0607/037cb11817fa372c1947 to your computer and use it in GitHub Desktop.
#!/bin/bash
volume=$(amixer sget Master | grep -o -m 1 '[[:digit:]]*%' | tr -d '%')
if [ -n "$2" ]
then
percent_change=$2
else
percent_change=5
fi
case "$1" in
up)
volume=$((volume + percent_change))
if [ $volume -gt 100 ]
then
volume=100
fi
amixer sset Master $volume% unmute
;;
down)
volume=$((volume - percent_change))
if [ $volume -lt 0 ]
then
volume=0
fi
amixer sset Master $volume% unmute
;;
set)
volume=$2
amixer sset Master $volume% unmute
;;
toggle)
amixer sset Master toggle
;;
mute)
amixer sset Master mute
;;
unmute)
amixer sset Master unmute
;;
esac
echo $volume
if [ -n "$(amixer sget Master | grep -o -m 1 'off')" ]
then
notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-muted-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
elif [ "$volume" -eq "0" ]
then
notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-low-zero-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
elif [ "$volume" -le "33" ]
then
notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-low-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
elif [ "$volume" -lt "66" ]
then
notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-medium-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
else
notify-send " " -i "/usr/share/icons/Numix/24x24/status/audio-volume-high-panel.svg" -h int:value:$volume -h string:x-canonical-private-synchronous:volume
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment