forked from mirrors_public/oddlama_nix-config
feat: add brightness keybinds and notification
This commit is contained in:
parent
4d42043895
commit
a6c643d8b1
6 changed files with 73 additions and 4 deletions
30
pkgs/scripts/brightness.nix
Normal file
30
pkgs/scripts/brightness.nix
Normal 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
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue