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