mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: add low battery indicator
This commit is contained in:
parent
aee51f5b09
commit
3ba1690e3a
4 changed files with 72 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ _:
|
|||
# ./safeeyes.nix
|
||||
./distrobox.nix
|
||||
./lid.nix
|
||||
./lowbattery.nix
|
||||
];
|
||||
|
||||
nixpkgs.config.permittedInsecurePackages = [
|
||||
|
|
|
|||
26
profiles/common/nixos/lowbattery.nix
Normal file
26
profiles/common/nixos/lowbattery.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{
|
||||
systemd.user.services."battery-low" = {
|
||||
enable = true;
|
||||
description = "Notify user if battery is below 10%";
|
||||
partOf = [ "graphical-session.target" ];
|
||||
wantedBy = [ "graphical-session.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+")));
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -26,8 +26,12 @@
|
|||
# secure boot
|
||||
sbctl
|
||||
|
||||
# nix package database
|
||||
nix-index
|
||||
|
||||
# proc info
|
||||
acpi
|
||||
|
||||
# better make for general tasks
|
||||
just
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue