wowlan: move the implementation into sxmo_suspend.sh instead of a systemd service

This commit is contained in:
2023-10-10 09:26:48 +00:00
parent c493fcfd7f
commit 2de947d96e
4 changed files with 17 additions and 9 deletions

View File

@@ -23,12 +23,6 @@
sane.zsh.showDeadlines = false; # unlikely to act on them when in shell
sane.services.wg-home.enable = true;
sane.services.wg-home.ip = config.sane.hosts.by-name."moby".wg-home.ip;
sane.wowlan.enable = true;
sane.wowlan.patterns = [
{ tcp.destPort = 22; } # wake on SSH
{ tcp.sourcePort = 2587; } # wake on `ntfy-sh` push from servo
{ arp.destIp = "10.78.79.54"; } # wake when somebody is doing an ARP query against us
];
# XXX colin: phosh doesn't work well with passwordless login,
# so set this more reliable default password should anything go wrong

View File

@@ -91,7 +91,7 @@ let
suspend = pkgs.static-nix-shell.mkBash {
pname = "sxmo_suspend.sh";
src = ./hooks;
pkgs = [ "util-linux" ];
pkgs = [ "coreutils" "rtl8723cs-wowlan" "time" "util-linux" ];
};
};
in

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p util-linux
#!nix-shell -i bash -p coreutils -p rtl8723cs-wowlan -p time -p util-linux
# yeah, this isn't technically a hook, but the hook infrastructure isn't actually
# restricted to stuff that starts with sxmo_hook_ ...
@@ -9,9 +9,20 @@
suspend_time=300
rtl8723cs-wowlan enable-clean
# wake on ssh
rtl8723cs-wowlan tcp --dest-port 22
# wake on notification (ntfy/Universal Push)
rtl8723cs-wowlan tcp --source-port 2587
# wake if someone doesn't know how to route to us, because that could obstruct the above
rtl8723cs-wowlan arp --dest-ip 10.78.79.54
echo "calling suspend for duration: $suspend_time"
rtcwake -m mem -s "$suspend_time" || exit 1
# XXX: run this in `env` to get the `time` binary instead of the builtin
elapsed="$(env time -f "%e" rtcwake -m mem -s $suspend_time)" || exit 1
echo "suspended for $elapsed seconds"
sxmo_hook_postwake.sh

View File

@@ -56,6 +56,9 @@
# - CONFIG_ROAMING_FLAG = 0x3
# - may fail to wake on LAN, even without any signature like the above
# - observed after a suspension of 10 minutes, trying to contact from laptop (laptop would have previously not contacted moby)
#
# TODO: remove this file
# it's been obsoleted by hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh
{ config, lib, pkgs, ... }: