Restructure
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
batteryNotify = pkgs.writeShellScript "battery-notify" ''
|
||||
BAT="/sys/class/power_supply/BAT1"
|
||||
LEVEL=$(cat "$BAT/capacity")
|
||||
STATUS=$(cat "$BAT/status")
|
||||
|
||||
if [ "$STATUS" = "Discharging" ] && [ "$LEVEL" -lt 90 ]; then
|
||||
${pkgs.dunst}/bin/dunstify \
|
||||
-r 9991 \
|
||||
-t 0 \
|
||||
-u critical \
|
||||
"Battery Low" \
|
||||
"Battery is at ''${LEVEL}%"
|
||||
else
|
||||
${pkgs.dunst}/bin/dunstify \
|
||||
-C 9991 2>/dev/null || true
|
||||
fi
|
||||
'';
|
||||
in
|
||||
{
|
||||
systemd.user.services.battery-notify = {
|
||||
Unit = {
|
||||
Description = "Low battery notification";
|
||||
After = [ "dunst.service" ];
|
||||
Requires = [ "dunst.service" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = batteryNotify;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.battery-notify = {
|
||||
Unit = {
|
||||
Description = "Check battery level every 20 seconds";
|
||||
};
|
||||
|
||||
Timer = {
|
||||
OnBootSec = "20s";
|
||||
OnUnitActiveSec = "20s";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
{
|
||||
imports = [
|
||||
./battery
|
||||
./btop
|
||||
./dunst
|
||||
./eza
|
||||
|
||||
@@ -54,10 +54,8 @@
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
libinput
|
||||
nodejs
|
||||
gnupg
|
||||
age
|
||||
eza
|
||||
yazi
|
||||
gitui
|
||||
bind
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
imports =
|
||||
[
|
||||
./hardware-configuration.nix
|
||||
|
||||
../../modules/battery
|
||||
];
|
||||
|
||||
boot.blacklistedKernelModules = [
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{ 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