1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

feat: add brightness keybinds and notification

This commit is contained in:
oddlama 2023-10-16 16:33:20 +02:00
parent 4d42043895
commit a6c643d8b1
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
6 changed files with 73 additions and 4 deletions

View file

@ -0,0 +1,30 @@
{
writeShellApplication,
bc,
libnotify,
brightnessctl,
}:
writeShellApplication {
name = "brightness";
text = ''
set -euo pipefail
${brightnessctl}/bin/brightnessctl "$1" "$2"
case "$2" in
"+"*) image=${./assets}/brightness-increase.svg ;;
*"-") image=${./assets}/brightness-decrease.svg ;;
esac
max=$(${brightnessctl}/bin/brightnessctl -m max)
value=$(${brightnessctl}/bin/brightnessctl -m get)
value=$(${bc}/bin/bc <<< "scale=0; 100*$value/$max")
${libnotify}/bin/notify-send \
"Brightness" \
--hint=string:image-path:"$image" \
--hint=int:value:"$value" \
--hint="string:wired-tag:indicator" \
--hint="string:wired-note:brightness" \
--expire-time=1000 \
|| true
'';
}