This askUbuntu post explains the correct way to execute a script on resume from suspend with systemd. You just place a script like this sleep-initiate.sh in /lib/systemd/system-sleep/:
#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin
case "$1" in
pre)
#code execution BEFORE sleeping/hibernating/suspending
;;
post)
#code execution AFTER resuming
sleep 10
/usr/bin/flatpak run com.google.Chrome
;;
esac
exit 0
I've gotten it to work with simple Linux commands, but it will not work launching Flatpaks as shown above. Why? Is it something to do with the Flatpak environment not being ready immediately upon my computer waking from sleep?