Add battery timer and btop
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.btop = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
color_theme = "Default";
|
||||||
|
theme_background = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./btop
|
||||||
./dunst
|
./dunst
|
||||||
./eza
|
./eza
|
||||||
./fastfetch
|
./fastfetch
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
|
||||||
|
../../modules/battery
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.blacklistedKernelModules = [
|
boot.blacklistedKernelModules = [
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
batteryNotify = pkgs.writeShellScript "battery-notify" ''
|
||||||
|
BAT="/sys/class/power_supply/BAT1"
|
||||||
|
LEVEL=$(cat "$BAT/capacity")
|
||||||
|
STATUS=$(cat "$BAT/status")
|
||||||
|
ID=9991
|
||||||
|
|
||||||
|
if [ "$STATUS" = "Discharging" ] && [ "$LEVEL" -lt 20 ]; then
|
||||||
|
${pkgs.dunst}/bin/dunstify \
|
||||||
|
-r "$ID" -t 0 \
|
||||||
|
-u critical \
|
||||||
|
"Battery Low" \
|
||||||
|
"Battery is at ''${LEVEL}%"
|
||||||
|
else
|
||||||
|
${pkgs.dunst}/bin/dunstify \
|
||||||
|
-C "$ID" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
systemd.services.battery-notify = {
|
||||||
|
description = "Low battery notification";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = batteryNotify;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers.battery-notify = {
|
||||||
|
description = "Check battery level every 20 seconds";
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
|
||||||
|
timerConfig = {
|
||||||
|
OnBootSec = "20s";
|
||||||
|
OnUnitActiveSec = "20s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user