2023-10-08 01:57:01 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2023-10-10 09:26:48 +00:00
|
|
|
#!nix-shell -i bash -p coreutils -p rtl8723cs-wowlan -p time -p util-linux
|
2023-10-08 01:57:01 +00:00
|
|
|
|
|
|
|
# yeah, this isn't technically a hook, but the hook infrastructure isn't actually
|
|
|
|
# restricted to stuff that starts with sxmo_hook_ ...
|
|
|
|
#
|
|
|
|
# this script is only called by sxmo_autosuspend, which is small, so if i wanted to
|
|
|
|
# be more proper i could instead re-implement autosuspend + integrations.
|
|
|
|
|
2023-10-08 04:16:37 +00:00
|
|
|
suspend_time=300
|
2023-10-08 01:57:01 +00:00
|
|
|
|
2023-10-10 09:50:13 +00:00
|
|
|
doas rtl8723cs-wowlan enable-clean
|
2023-10-10 09:26:48 +00:00
|
|
|
# wake on ssh
|
2023-10-10 09:50:13 +00:00
|
|
|
doas rtl8723cs-wowlan tcp --dest-port 22
|
2023-10-10 09:26:48 +00:00
|
|
|
# wake on notification (ntfy/Universal Push)
|
2023-10-10 09:50:13 +00:00
|
|
|
doas rtl8723cs-wowlan tcp --source-port 2587
|
2023-10-10 09:26:48 +00:00
|
|
|
# wake if someone doesn't know how to route to us, because that could obstruct the above
|
2023-10-10 09:50:13 +00:00
|
|
|
doas rtl8723cs-wowlan arp --dest-ip 10.78.79.54
|
2023-10-10 09:26:48 +00:00
|
|
|
|
2023-10-10 00:35:32 +00:00
|
|
|
echo "calling suspend for duration: $suspend_time"
|
2023-10-08 01:57:01 +00:00
|
|
|
|
2023-10-10 10:05:09 +00:00
|
|
|
start="$(date "+%s")"
|
2023-10-10 09:47:41 +00:00
|
|
|
rtcwake -m mem -s "$suspend_time" || exit 1
|
2023-10-10 10:05:09 +00:00
|
|
|
#We woke up again
|
|
|
|
time_spent="$(( $(date "+%s") - start ))"
|
|
|
|
echo "suspended for $time_spent seconds"
|
2023-10-08 01:57:01 +00:00
|
|
|
|
|
|
|
sxmo_hook_postwake.sh
|
|
|
|
|