diff --git a/hosts/by-name/moby/default.nix b/hosts/by-name/moby/default.nix index 8bad7dc3f..35a12647d 100644 --- a/hosts/by-name/moby/default.nix +++ b/hosts/by-name/moby/default.nix @@ -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 diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index fbb3c1bff..e6c5ef387 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -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 diff --git a/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh b/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh index bfa43df5f..2aedef161 100755 --- a/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh +++ b/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh @@ -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 diff --git a/modules/wowlan.nix b/modules/wowlan.nix index 353fab14d..5e28e2dad 100644 --- a/modules/wowlan.nix +++ b/modules/wowlan.nix @@ -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, ... }: