Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4ba4fefc6 | ||
|
|
8bb925d9e7 | ||
|
|
7ad43db433 | ||
|
|
f4b0269b08 |
No files matched your search
Generated
+8
-8
@@ -81,11 +81,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794561158,
|
"lastModified": 1794751387,
|
||||||
"narHash": "sha256-1aeTxyWnFq9Vn+caG6blg2MrqN+cb8TA6Fwtj+z6Jwo=",
|
"narHash": "sha256-YwozcQTw7nu5OF5hc/PvLNThfEnwh4Jp4JAHw8zf2Ew=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "b07a67b94056da3be29ed4dd7e146bc6cfe6c15d",
|
"rev": "d9b04d1630a66a1edfb602ce17209d0a22ec7226",
|
||||||
"revCount": 48,
|
"revCount": 52,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git"
|
||||||
},
|
},
|
||||||
@@ -711,11 +711,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794560880,
|
"lastModified": 1794753916,
|
||||||
"narHash": "sha256-HszelndbRC0mlXyW6xZf3NXySj2CoehqoDq4P6QYlQ8=",
|
"narHash": "sha256-LEmknV/2DjQiOUmeuu2BuggZL1gGQ4wF22ozo8L24SQ=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "3684df521a4af58856cd81e1ad63cfe034c492f6",
|
"rev": "78fe43e96f406fda12ca450badc2e51122abb77f",
|
||||||
"revCount": 19,
|
"revCount": 30,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ in
|
|||||||
_args = [
|
_args = [
|
||||||
"SUPER + SHIFT + x"
|
"SUPER + SHIFT + x"
|
||||||
(lib.generators.mkLuaInline
|
(lib.generators.mkLuaInline
|
||||||
''hl.dsp.exec_cmd("${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend")''
|
''hl.dsp.exec_cmd("${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend-then-hibernate")''
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,17 +27,25 @@ in
|
|||||||
description = "Notify low battery at this level";
|
description = "Notify low battery at this level";
|
||||||
};
|
};
|
||||||
|
|
||||||
suspendCapacity = lib.mkOption {
|
hibernateCapacity = lib.mkOption {
|
||||||
default = 10;
|
default = 10;
|
||||||
description = "Warn at this level and then suspend if power is not plugged in";
|
description = "Warn at this level and then hibernate if power is not plugged in";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
swapDevices = lib.mkIf enabled [
|
||||||
|
{
|
||||||
|
device = "/var/lib/swapfile";
|
||||||
|
size = 64 * 1024; # MiB
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
services = lib.mkIf enabled {
|
services = lib.mkIf enabled {
|
||||||
upower = {
|
upower = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
criticalPowerAction = "Hibernate";
|
||||||
};
|
};
|
||||||
|
|
||||||
logind.settings.Login = {
|
logind.settings.Login = {
|
||||||
@@ -62,7 +70,7 @@ in
|
|||||||
timers = {
|
timers = {
|
||||||
"monitor-low-battery" = {
|
"monitor-low-battery" = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "monitors battery level and suspends computer if battery is low";
|
Description = "monitors battery level and hibernates computer if battery is low";
|
||||||
};
|
};
|
||||||
|
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
@@ -78,7 +86,7 @@ in
|
|||||||
services = {
|
services = {
|
||||||
"monitor-low-battery" = {
|
"monitor-low-battery" = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "monitors battery level and suspends computer if battery is low";
|
Description = "monitors battery level and hibernates computer if battery is low";
|
||||||
};
|
};
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
@@ -105,13 +113,13 @@ in
|
|||||||
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.suspendCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.hibernateCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||||
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Suspending in 60 seconds if power is not plugged in"
|
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Hibernating in 60 seconds if power is not plugged in"
|
||||||
sleep 60s
|
sleep 60s
|
||||||
|
|
||||||
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
||||||
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
||||||
${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend
|
${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl hibernate
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -75,7 +75,12 @@ let
|
|||||||
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
||||||
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
||||||
else
|
else
|
||||||
tailscale set --exit-node=$PREFERRED_EXIT_NODE && ${pkgs.libnotify}/bin/notify-send "Connected to Exit Node"
|
tailscale set --exit-node=$PREFERRED_EXIT_NODE || exit 1
|
||||||
|
|
||||||
|
EXIT_NODE_NAME=$(tailscale status --json | ${pkgs.jq}/bin/jq -r '
|
||||||
|
.Peer.[] | select(.ExitNode)
|
||||||
|
| .HostName + (if .Location then " (\(.Location.City), \(.Location.Country))" else "" end)')
|
||||||
|
${pkgs.libnotify}/bin/notify-send "Connected to Exit Node" "$EXIT_NODE_NAME"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user