Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.95 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # listen to acpi events and handle them
  4. # for now assumes user is in x env and has notification system
  5. # a bit of a hello world
  6.  
  7. coproc acpi_listen
  8. trap 'kill $COPROC_PID' EXIT
  9.  
  10. while read -u ${COPROC[0]} -a event; do
  11.     if [ "${event[0]}" = 'button/mute' ]
  12.     then
  13.     amixer set Master toggle
  14.         sound_state=$(amixer get Master | grep -oE "\[on\]|\[off\]")
  15.     case $sound_state in
  16.         "[on]")
  17.         notify-send "Sound is on."
  18.         ;;
  19.         "[off]")
  20.         notify-send "Sound is off."
  21.         ;;
  22.         *)
  23.         notify-send "Master Channel entered unkown state."
  24.         ;;
  25.     esac
  26.     fi
  27.     if [ "${event[0]} = 'button/volumedown'" ]
  28.     then
  29.     amixer sset Master 5%- ummute
  30.     volume=$(amixer get Master | grep Mono | cut -c22-24)
  31.     notify-send "Sound: $volume"
  32.     fi
  33.     if [ "${event[0]} = 'button/volumeup'" ]
  34.     then
  35.     amixer sset Master 5%+ ummute
  36.     volume=$(amixer get Master | grep Mono | cut -c22-24)
  37.     notify-send "Sound: $volume"
  38.     fi
  39. done
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement