Skip to content

Instantly share code, notes, and snippets.

@imAliAzhar
Created October 7, 2018 20:27
Show Gist options
  • Save imAliAzhar/e4fe1ac7ecdba8c1e2690b5606507e3a to your computer and use it in GitHub Desktop.
Save imAliAzhar/e4fe1ac7ecdba8c1e2690b5606507e3a to your computer and use it in GitHub Desktop.
Script to get brightness notification with dunst.
#!/bin/bash
# You can call this script like this:
# $./brightness.sh up
# $./brightness.sh down
# Based on sebastiencs' script (https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a)
function get_brightness {
xbacklight -get
}
function send_notification {
brightness=`get_brightness`
brightness=${brightness%%.*}
# Make the bar with the special character (it's not dash -) Make sure it's not replaced by '?'
# https://en.wikipedia.org/wiki/Box-drawing_character
bar=$(seq -s "" $(($brightness / 5)) | sed 's/[0-9]//g')
#Send the notification
case $brightness in
100)
dunstify -i audio-brightness-muted-blocking -r 2593 -t 1000 -u normal "Brightness $brightness: $bar"
;;
*)
dunstify -i audio-brightness-muted-blocking -r 2593 -t 1000 -u normal "Brightness $brightness: $bar"
;;
esac
}
case $1 in
up)
xbacklight -inc 5
send_notification
;;
down)
xbacklight -dec 5
send_notification
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment