dunst-backlight-indicator.sh 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # changeBrightness
  4. # Arbitrary but unique message id
  5. msgId="990961"
  6. # Change the Brightness using alsa(might differ if you use pulseaudio)
  7. xbacklight "$@" > /dev/null
  8. ########## FIX THIS SCRIPT (ON LAPTOP THIS WILL BE EASIEST TO SETUP)
  9. # Query amixer for the current Brightness and whether or not the speaker is muted
  10. brightness="$(xbacklight)"
  11. mute="$(amixer -c 0 get Master | tail -1 | awk '{print $6}' | sed 's/[^a-z]*//g')"
  12. if [[ $brightness == 0 || "$mute" == "off" ]]; then
  13. # Show the sound muted notification
  14. dunstify -a "changeBrightness" -u low -i display-brightness-low "$msgId" "Brightness low"
  15. # dunstify -a "changeBrightness" -u low -i display-brightness-medium "$msgId" "Brightness medium"
  16. # dunstify -a "changeBrightness" -u low -i display-brightness-high "$msgId" "Brightness full"
  17. else
  18. # Show the Brightness notification
  19. dunstify -a "changeBrightness" -u low -i audio-Brightness-high -r "$msgId" \
  20. -h int:value:"$brightness" "Brightness: ${brightness}%"
  21. fi
  22. # # Play the Brightness changed sound
  23. # canberra-gtk-play -i audio-Brightness-change -d "changeBrightness"