mirror of
https://github.com/anotherhadi/nixy.git
synced 2026-04-02 19:12:11 +02:00
change my keyboard backlight depending on the battery lvl
This commit is contained in:
@@ -16,6 +16,7 @@ in {
|
||||
./animations.nix
|
||||
./bindings.nix
|
||||
./polkitagent.nix
|
||||
./keyboard-backlight.nix # CHANGEME: This is for my laptop only
|
||||
# FIXME: Broken on unstable
|
||||
# ./hyprspace.nix
|
||||
];
|
||||
|
||||
32
home/system/hyprland/keyboard-backlight.nix
Normal file
32
home/system/hyprland/keyboard-backlight.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
# Turn the keyboard red/off when the battery is low
|
||||
{ pkgs, config, ... }:
|
||||
let
|
||||
keyboard-backlight = pkgs.writeShellScriptBin "keyboard-backlight" ''
|
||||
function set_keyboard_backlight {
|
||||
local color=$1
|
||||
echo $color > /sys/devices/platform/hp-wmi/rgb_zones/zone00
|
||||
echo $color > /sys/devices/platform/hp-wmi/rgb_zones/zone01
|
||||
echo $color > /sys/devices/platform/hp-wmi/rgb_zones/zone02
|
||||
echo $color > /sys/devices/platform/hp-wmi/rgb_zones/zone03
|
||||
}
|
||||
state="white"
|
||||
while true; do
|
||||
BATTERY_LEVEL=$(cat /sys/class/power_supply/BAT*/capacity)
|
||||
if [[ $BATTERY_LEVEL -le 10 ]]; then
|
||||
if [[ $state == "red" ]];then
|
||||
state="white"
|
||||
set_keyboard_backlight "000000"
|
||||
else
|
||||
state="red"
|
||||
set_keyboard_backlight "FF0000"
|
||||
fi
|
||||
else
|
||||
state="white"
|
||||
set_keyboard_backlight ${config.lib.stylix.colors.base0D}
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
'';
|
||||
in {
|
||||
wayland.windowManager.hyprland.settings.exec-once = [ keyboard-backlight ];
|
||||
}
|
||||
Reference in New Issue
Block a user