Files
nixy/home/system/hyprland/keyboard-backlight.nix
KptltD00M 5082521524 Add new server modules and configurations for various services
- Introduced `default-creds` module for managing default credentials with Umami integration.
- Added `fail2ban` module for brute-force attack protection with configurable ban times.
- Created `firewall` module to enable and configure basic firewall settings.
- Implemented `gitea` module for self-hosted Git service with PostgreSQL backend.
- Developed `glance` module for a customizable dashboard with various widgets and themes.
- Added `iknowyou` module for a self-hosted password manager with production and demo environments.
- Introduced `kernel-hardening` module for enhancing kernel security settings.
- Created `mazanoke` module for a simple web application with Nginx integration.
- Added `mealie` module for a self-hosted meal planning application.
- Implemented `stirling-pdf` module for PDF generation service.
- Developed `umami` module for self-hosted analytics with secret management.
- Added `ssh` module for secure SSH configuration with user restrictions.
- Introduced `nixy` theme for a customized aesthetic experience across services.
2026-06-16 23:03:39 +02:00

45 lines
1.4 KiB
Nix

# Turn the keyboard red/off when the battery is low
# Include this one only if you have a omen laptop with RGB keyboard
{
pkgs,
config,
...
}: let
alert-when-low-battery = false;
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"
set_keyboard_backlight ${config.lib.stylix.colors.base0D}
if [ "${toString alert-when-low-battery}" = "false" ]; then
exit 0
fi
while true; do
BATTERY_LEVEL=$(cat /sys/class/power_supply/BAT*/capacity)
IS_CHARGING=$(cat /sys/class/power_supply/BAT*/status)
if [[ $BATTERY_LEVEL -le 10 && $IS_CHARGING != "Charging" ]]; 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
'';
command = "bash ${keyboard-backlight}/bin/keyboard-backlight &";
in {
wayland.windowManager.hyprland.settings.exec-once = [command];
}