The purpose of the script is to re-enable a hidden SSID upon resume from sleep. Somehow the ability to restart a hidden SSID automatically was lost when I upgraded from 18.04 LTS to 20.04 LTS.
You can see from the script below how many ways I have tried to get this to work. The echo
print to suspend.txt
works every time upon resume. It is just the portion to restart the wifi that does not work.
All the commands I tried in the script work as expected when entered on the CLI and the /home/user/Desktop/wifi-ssid.sh
works when double clicked.
The results from journalctl | grep systemd-sleep
is below the script. Most notable is the error...
"Error: Connection activation failed: No suitable device found for this connection (device lo not available because device is strictly unmanaged)."
This must be something simple. Please help.
#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/home/user/Desktop
case "$1" in
pre)
#code execution BEFORE sleeping/hibernating/suspending
;;
post)
#code execution AFTER resuming
echo "$(date) - $1: test pre" >> /home/user/tmp/suspend.txt
/usr/bin/nmcli c up id "SSID"
#/usr/bin/nmcli radio wifi on
#sleep 2
#/usr/bin/nmcli c up id "SSID"
#/home/user/Desktop/wifi-ssid.sh
#su user -c "/home/user/Desktop/wifi-ssid.sh"
#su user -c "/usr/bin/nmcli c up id "SSID""
#/usr/bin/sudo -u user bash -c "export XDG_RUNTIME_DIR=/run/user/1000; /home/user/Desktop/wifi-ssid.sh"
#/usr/bin/sudo -u user bash -c "export XDG_RUNTIME_DIR=/run/user/1000; /usr/bin/nmcli c up id "SSID""
#/usr/bin/sudo -u user bash -c "/home/user/Desktop/wifi-ssid.sh"
#su user -c "/usr/bin/nmcli con up SSID"
#/usr/bin/sudo -u user bash -c "export XDG_RUNTIME_DIR=/run/user/1000; /usr/bin/nmcli con up SSID; /usr/bin/nmcli radio wifi on; sleep 2; /usr/bin/nmcli c up id "SSID""
;;
esac
exit 0
journalctl | grep systemd-sleep
shows the following:
Mar 03 16:53:30 User systemd-sleep[4074]: Suspending system...
Mar 03 20:01:32 User systemd-sleep[4074]: System resumed.
Mar 03 20:01:32 User systemd-sleep[4206]: /dev/sda:
Mar 03 20:01:32 User systemd-sleep[4206]: setting Advanced Power Management level to 0xfe (254)
Mar 03 20:01:32 USer systemd-sleep[4206]: APM_level = 0
Mar 03 20:01:32 User systemd-sleep[4189]: Error: Connection activation failed: No suitable device found for this connection (device lo not available because device is strictly unmanaged).
username
to e.g. your actual account login user name ... If so, then your command requires elevated privileges to execute and specifyingroot
as a user is mandatory in such case. – Raffa Mar 04 '23 at 19:02