Skip to content

Instantly share code, notes, and snippets.

@basilioss
Forked from Blaradox/brightnessControl.sh
Last active July 13, 2022 17:17
Show Gist options
  • Save basilioss/baa36bf5d4b91b50da81313281dbc887 to your computer and use it in GitHub Desktop.
Save basilioss/baa36bf5d4b91b50da81313281dbc887 to your computer and use it in GitHub Desktop.
Notifications for brightness and volume, using dunstify
#!/usr/bin/env bash
# You can call this script like this:
# $ ./brightness-control.sh up
# $ ./brightness-control.sh down
# Script inspired by these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
# Icon path: /usr/share/icons/Papirus/16x16/apps
icon="display-brightness"
function get_brightness {
xbacklight -get | cut -d '.' -f 1
}
function send_notification {
dunstify -i "$icon" -r 5555 -u normal -h int:value:"$1" "Brightness: $1%"
}
case $1 in
up)
xbacklight -inc 5
send_notification "$(get_brightness)"
;;
down)
xbacklight -dec 5
send_notification "$(get_brightness)"
;;
esac
#!/usr/bin/env bash
# You can call this script like this:
# $ ./volume-control.sh up
# $ ./volume-control.sh down
# $ ./volume-control.sh mute
# Script modified from these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
iconSound="audio-volume-high"
iconMuted="audio-volume-muted"
function get_volume {
pamixer --get-volume
}
function send_notification {
if [ "$(pamixer --get-mute)" = true ]; then
dunstify -i $iconMuted -r 2593 -u normal "mute"
else
dunstify -i $iconSound -r 2593 -u normal -h int:value:"$1" "Volume: $1%"
fi
}
case $1 in
up)
pamixer --unmute
pamixer --increase 5
send_notification "$(get_volume)"
;;
down)
pamixer --unmute
pamixer --decrease 5
send_notification "$(get_volume)"
;;
mute)
pamixer --toggle-mute
send_notification "$(get_volume)"
;;
esac
@basilioss
Copy link
Author

20220713_201650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment