dunst: Add brightness level notifications
Added notifications on changing brightness, will stack by default to show the current level before disappearing. The script to change and notify can be run through the command `control-brightness`, and is bound to the sxhkd media key shortcuts for brightness changes. Removed the brightness indicator from polybar since it should be easy enough to check current brightness by doing a quick higher-lower and that's it. Kept the module in polybar configuration script since I might reconsider its removal if it turns out to have been useful.
This commit is contained in:
parent
0a6f47bc5a
commit
d2e44d330d
4 changed files with 64 additions and 7 deletions
|
@ -95,3 +95,4 @@ transnationalism
|
||||||
universalisms
|
universalisms
|
||||||
univseralism
|
univseralism
|
||||||
weaponization
|
weaponization
|
||||||
|
blog
|
||||||
|
|
|
@ -57,9 +57,9 @@ padding-left = 0
|
||||||
padding-right = 0
|
padding-right = 0
|
||||||
module-margin-left = 2
|
module-margin-left = 2
|
||||||
|
|
||||||
modules-left = workspaces sxhkdmode pomo papersdue
|
modules-left = sxhkdmode workspaces pomo papersdue
|
||||||
modules-center = music date
|
modules-center = music date
|
||||||
modules-right = networkspeed mail weather archupdates cpu temp backlight volume battery
|
modules-right = networkspeed mail weather archupdates cpu temp volume battery
|
||||||
; do not use offsets for the bar, would only work with override-redirect
|
; do not use offsets for the bar, would only work with override-redirect
|
||||||
; and will mess up tray https://github.com/polybar/polybar/issues/1355
|
; and will mess up tray https://github.com/polybar/polybar/issues/1355
|
||||||
tray-position = right
|
tray-position = right
|
||||||
|
@ -130,7 +130,7 @@ ws-icon-default = ♟
|
||||||
; Default: %icon% %name%
|
; Default: %icon% %name%
|
||||||
; unfocused = Inactive workspace on any monitor
|
; unfocused = Inactive workspace on any monitor
|
||||||
label-unfocused = %icon%
|
label-unfocused = %icon%
|
||||||
label-unfocused-padding = 4
|
label-unfocused-padding = 2
|
||||||
label-unfocused-underline = ${colors.background-alt}
|
label-unfocused-underline = ${colors.background-alt}
|
||||||
; focused = Active workspace on focused monitor
|
; focused = Active workspace on focused monitor
|
||||||
label-focused = %icon%
|
label-focused = %icon%
|
||||||
|
@ -212,7 +212,7 @@ format-underline = ${colors.primary}
|
||||||
[module/date]
|
[module/date]
|
||||||
type = internal/date
|
type = internal/date
|
||||||
; Seconds to sleep between updates
|
; Seconds to sleep between updates
|
||||||
interval = 1.0
|
interval = 5.0
|
||||||
; See "http://en.cppreference.com/w/cpp/io/manip/put_time" for details on how to format the date string
|
; See "http://en.cppreference.com/w/cpp/io/manip/put_time" for details on how to format the date string
|
||||||
; NOTE: if you want to use syntax tags here you need to use %%{...}
|
; NOTE: if you want to use syntax tags here you need to use %%{...}
|
||||||
date = %d/%m
|
date = %d/%m
|
||||||
|
@ -221,8 +221,8 @@ time = %H:%M
|
||||||
; if `date-alt` or `time-alt` is defined, clicking
|
; if `date-alt` or `time-alt` is defined, clicking
|
||||||
; the module will toggle between formats
|
; the module will toggle between formats
|
||||||
date-alt = %A, %d %B %Y (W %V)
|
date-alt = %A, %d %B %Y (W %V)
|
||||||
time-alt = %H:%M
|
time-alt = %H:%M:%S
|
||||||
label = %date%%{T2} %{T-}%time%
|
label = %date%%{T2} %{T-}%time%
|
||||||
format-underline = ${colors.primary}
|
format-underline = ${colors.primary}
|
||||||
|
|
||||||
; display information on currently playing track, allows simple track manipulation
|
; display information on currently playing track, allows simple track manipulation
|
||||||
|
@ -295,6 +295,7 @@ format-underline = ${colors.primary}
|
||||||
[module/networkspeed]
|
[module/networkspeed]
|
||||||
type = custom/script
|
type = custom/script
|
||||||
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-networkspeed
|
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-networkspeed
|
||||||
|
exec-if = type $XDG_CONFIG_HOME/polybar/scripts/poly-networkspeed
|
||||||
tail = true
|
tail = true
|
||||||
format-underline = ${colors.primary}
|
format-underline = ${colors.primary}
|
||||||
|
|
||||||
|
|
55
scripts/.local/bin/control-brightness
Executable file
55
scripts/.local/bin/control-brightness
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
# Brightness control script using xbacklight
|
||||||
|
# Will use notify-send to create brightness notifications, if dunst is used
|
||||||
|
# or the notification daemon supports tag stacks, will automatically update
|
||||||
|
# the same notifications and not create new ones.
|
||||||
|
#
|
||||||
|
# inspired from https://gist.github.com/Blaradox/030f06d165a82583ae817ee954438f2e
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: control-brightness up|down [step], where step can be any int value
|
||||||
|
or: control-brightness set target, where target can be an int value 0-100"
|
||||||
|
}
|
||||||
|
|
||||||
|
direction=$1
|
||||||
|
step=${2:-10}
|
||||||
|
|
||||||
|
get_brightness() {
|
||||||
|
xbacklight -get | cut -d. -f1
|
||||||
|
}
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
icon="preferences-system-brightness-lock"
|
||||||
|
brightness=$(get_brightness)
|
||||||
|
# Make the bar with the special character ─ (it's not dash -)
|
||||||
|
# https://en.wikipedia.org/wiki/Box-drawing_character
|
||||||
|
bar=$(seq -s "─" 0 $((brightness / 5)) | sed 's/[0-9]//g' |
|
||||||
|
sed -e 's/^─/┠/' -e 's/^\(.\{20\}\)/\1┫/')
|
||||||
|
if type dunstify 1>/dev/null 2>/dev/null; then
|
||||||
|
dunstify -i "$icon" -u normal " $bar" -a "xbacklight" -h string:x-dunst-stack-tag:brightness
|
||||||
|
else
|
||||||
|
notify-send -i "$icon" -u normal " $bar" -a "xbacklight" -h string:x-dunst-stack-tag:brightness
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case $direction in
|
||||||
|
up)
|
||||||
|
xbacklight -inc "$step"
|
||||||
|
send_notification
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
xbacklight -dec "$step"
|
||||||
|
send_notification
|
||||||
|
;;
|
||||||
|
set)
|
||||||
|
if [ -z "$step" ]; then
|
||||||
|
echo "set option requires target brightness to be specified."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
xbacklight -set "$step"
|
||||||
|
send_notification
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: control-brightness up|down [step], where step can be any int value"
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -19,7 +19,7 @@ super + F7
|
||||||
|
|
||||||
# enable function (/media) key functionality
|
# enable function (/media) key functionality
|
||||||
XF86MonBrightness{Up,Down}
|
XF86MonBrightness{Up,Down}
|
||||||
xbacklight {-inc,-dec} 10
|
control-brightness {up, down} 10
|
||||||
XF86AudioMute
|
XF86AudioMute
|
||||||
pavolume mutetoggle
|
pavolume mutetoggle
|
||||||
XF86Audio{LowerVolume,RaiseVolume}
|
XF86Audio{LowerVolume,RaiseVolume}
|
||||||
|
|
Loading…
Reference in a new issue