{ pkgs, ... }: { systemd.user.services.battery-monitor = { description = "Battery level monitor with hyprctl notifications"; wantedBy = [ "default.target" ]; after = [ "graphical-session.target" ]; serviceConfig = { Type = "oneshot"; ExecStart = pkgs.writeShellScript "battery-monitor" '' #!/usr/bin/env bash # Get battery percentage BATTERY_LEVEL=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null | head -1) # Check if battery level was found if [ -z "$BATTERY_LEVEL" ]; then exit 0 fi # Check if battery is below 20% if [ "$BATTERY_LEVEL" -le 20 ]; then # Get battery status (charging/discharging) BATTERY_STATUS=$(cat /sys/class/power_supply/BAT*/status 2>/dev/null | head -1) # Only notify if discharging if [ "$BATTERY_STATUS" = "Discharging" ]; then ${pkgs.hyprland}/bin/hyprctl notify -1 10000 "rgb(ff1744)" "Battery Low: $BATTERY_LEVEL%" fi fi ''; }; }; systemd.user.timers.battery-monitor = { description = "Run battery monitor every 2 minutes"; wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "2min"; OnUnitActiveSec = "2min"; Unit = "battery-monitor.service"; }; }; }