Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # listen to acpi events and handle them
- # for now assumes user is in x env and has notification system
- # a bit of a hello world
- coproc acpi_listen
- trap 'kill $COPROC_PID' EXIT
- while read -u ${COPROC[0]} -a event; do
- if [ "${event[0]}" = 'button/mute' ]
- then
- amixer set Master toggle
- sound_state=$(amixer get Master | grep -oE "\[on\]|\[off\]")
- case $sound_state in
- "[on]")
- notify-send "Sound is on."
- ;;
- "[off]")
- notify-send "Sound is off."
- ;;
- *)
- notify-send "Master Channel entered unkown state."
- ;;
- esac
- fi
- if [ "${event[0]} = 'button/volumedown'" ]
- then
- amixer sset Master 5%- ummute
- volume=$(amixer get Master | grep Mono | cut -c22-24)
- notify-send "Sound: $volume"
- fi
- if [ "${event[0]} = 'button/volumeup'" ]
- then
- amixer sset Master 5%+ ummute
- volume=$(amixer get Master | grep Mono | cut -c22-24)
- notify-send "Sound: $volume"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement