I'm running Pop!_OS, a Ubuntu based OS, and I want to run nordvpn disconnect before suspend and nordvpn connect after suspend. I'm using code from this arch linux wiki and can't get the nordvpn connect/nordvpn disconnect commands to run on system wake. I added the file 99nordvpn-reload to /lib/systemd/system-sleep/ and made it executable with sudo chmod a+x 99nordvpn-reload. The code in that file is:
#!/bin/sh
case $1/$2 in
pre/*)
nordvpn disconnect
;;
post/*)
nordvpn connect
;;
esac
waking from sleep, running journalctl -u systemd-suspend.service shows:
Jun 13 22:08:38 pop-os [4520]: /usr/lib/systemd/system-sleep/99nordvpn-reload failed with exit status 1.
I have also tried running the command as a local user with:
#!/bin/sh
case $1/$2 in
pre/*)
sudo -u $USER nordvpn disconnect
;;
post/*)
sudo -u $USER nordvpn connect
;;
esac
but $USER is replaced with the output from echo $USER. However, I get the same error message as before. I'm assuming this error has something to do with the nordvpn package being installed locally or my $USER, hence the attempt at executing the command with sudo -u $USER.
Based on this thread, I also attempted creating the globally executable file /usr/local/bin/nordvpn-reload with contents:
#!/bin/bash
nordvpn disconnect;nordvpn connect
and changing the contents of /lib/systemd/system-sleep/99nordvpn-reload to:
#!/bin/sh
case $1/$2 in
pre/*)
exit 0
;;
post/*)
/usr/local/bin/nordvpn-reload
;;
esac
but once again, I get the same error as always. Any suggestions/advice/further reading would be much appreciated.