-
-
Save basilioss/baa36bf5d4b91b50da81313281dbc887 to your computer and use it in GitHub Desktop.
Notifications for brightness and volume, using dunstify
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
#!/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 |
Author
basilioss
commented
Jul 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment