Created
March 1, 2013 18:34
-
-
Save unhammer/5066729 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
step=10 | |
# Workaround; analog-output-headphones never works, yet is switched to | |
# whenever I plug in headphones | |
pacmd set-sink-port 0 analog-output | |
vol=$(ponymix get-volume) | |
case "$1" in | |
increase) | |
if [[ $(( $vol + $step)) -gt 100 ]]; then | |
vol=$(ponymix set-volume 100) | |
else | |
vol=$(ponymix $1 $step) | |
fi | |
;; | |
decrease) | |
if [[ $(( $vol - $step)) -lt 0 ]]; then | |
vol=$(ponymix set-volume 0) | |
else | |
vol=$(ponymix $1 $step) | |
fi | |
;; | |
toggle) | |
ponymix $1 | |
;; | |
*) | |
echo "Error! Usage: $0 {increase|decrease|toggle}" | |
exit 1 | |
;; | |
esac | |
if ponymix is-muted; then | |
icon=audio-volume-muted | |
elif [[ $vol -eq 0 ]]; then | |
icon=audio-volume-off | |
elif [[ $vol -lt 30 ]]; then | |
icon=audio-volume-low | |
elif [[ $vol -lt 60 ]]; then | |
icon=audio-volume-medium | |
else | |
icon=audio-volume-high | |
fi | |
if type yad 2>/dev/null; then | |
yad --text "$vol" --geometry -65+0 --undecorated --skip-taskbar --no-buttons --timeout 1 --image /usr/share/icons/elementary-xfce/notifications/48/$icon.svg | |
else | |
notify-send -i $icon "$vol" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment