Skip to content

Commit

Permalink
feat: add udev rule for automatic power off on low battery
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-qwt committed Feb 12, 2025
1 parent b6b18f8 commit a2b1870
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hosts/lei/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{ config, pkgs, lib, ... }:
let
systemctl = lib.getExe' config.systemd.package "systemctl";
in
{
boot.kernelPatches = [ ];

Expand Down Expand Up @@ -51,4 +53,8 @@
myos.tailscale.enable = true;

myos.container.enable = true;

services.udev.extraRules = ''
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${systemctl} poweroff"
'';
}

0 comments on commit a2b1870

Please sign in to comment.