machines/smithers: Added battery warning via keyboard blinking
This commit is contained in:
parent
8f8615eeae
commit
e19b89e47d
2 changed files with 33 additions and 0 deletions
32
machines/smithers/batterylight.nix
Normal file
32
machines/smithers/batterylight.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
systemd.timers."batterylight" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "5m";
|
||||
Unit = "batterylight.service";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."batterylight" = {
|
||||
script = ''
|
||||
STATUS=`cat /sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT1/status`
|
||||
PERCENT=`cat /sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT1/capacity`
|
||||
if [[ $STATUS == "Discharging" && $PERCENT -lt 10 ]]; then
|
||||
for i in `seq 0 3`; do
|
||||
${pkgs.framework-tool}/bin/framework_tool --kblight 0
|
||||
sleep 0.2
|
||||
${pkgs.framework-tool}/bin/framework_tool --kblight 100
|
||||
sleep 0.2
|
||||
${pkgs.framework-tool}/bin/framework_tool --kblight 0
|
||||
sleep 0.2
|
||||
done
|
||||
fi
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
./hardware-configuration.nix
|
||||
../../roles/all.nix
|
||||
../../roles/laptop.nix
|
||||
./batterylight.nix
|
||||
|
||||
# import hardware specific settings
|
||||
<nixos-hardware/framework/13-inch/7040-amd>
|
||||
|
|
Loading…
Add table
Reference in a new issue