mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2026-04-15 05:39:11 +02:00
wip: migrate client modules
This commit is contained in:
parent
f6d2ff1544
commit
7ce27d5d2f
245 changed files with 20254 additions and 188 deletions
33
modules-clone/nixos/client/lowbattery.nix
Normal file
33
modules-clone/nixos/client/lowbattery.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
options.swarselmodules.lowBattery = lib.mkEnableOption "low battery notification config";
|
||||
config = lib.mkIf config.swarselmodules.lowBattery {
|
||||
systemd.user.services."battery-low" =
|
||||
let
|
||||
target = "sway-session.target";
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
description = "Timer for battery check that alerts at 10% or less";
|
||||
partOf = [ target ];
|
||||
wantedBy = [ target ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = pkgs.writeShellScript "battery-low-notification"
|
||||
''
|
||||
if (( 10 >= $(${lib.getExe pkgs.acpi} -b | head -n 1 | ${lib.getExe pkgs.ripgrep} -o "\d+%" | ${lib.getExe pkgs.ripgrep} -o "\d+") && $(${lib.getExe pkgs.acpi} -b | head -n 1 | ${lib.getExe pkgs.ripgrep} -o "\d+%" | ${lib.getExe pkgs.ripgrep} -o "\d+") > 0 ));
|
||||
then ${lib.getExe pkgs.libnotify} --urgency=critical "low battery" "$(${lib.getExe pkgs.acpi} -b | head -n 1 | ${lib.getExe pkgs.ripgrep} -o "\d+%")";
|
||||
fi;
|
||||
'';
|
||||
};
|
||||
};
|
||||
systemd.user.timers."battery-low" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
# Every Minute
|
||||
OnCalendar = "*-*-* *:*:00";
|
||||
Unit = "battery-low.service";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue