How to start a script after logging in AND WiFi is ready?
How to start a script after logging in AND WiFi is ready?
I try to download a file with curl directly after logging into Gnome. This usually fails because mostly the WiFi connection is only established after login. If I wait long enough in the login screen before logging in, the connection is already established and the download works.
So far I have used Manjaro. WiFi was already active long before the login screen of GDM was even displayed. The download therefore always worked.
The download is initiated with a *.desktop file in ~/.config/autostart.
Is there another way to start the download after the user is logged in and the WiFi connection is really ready?
Create a systemd user unit that waits for the network-online.target.
A script something like:
Edit the template according to your needs and dump it into
~/.local/share/systemd/user/<unit>.service
and enable it withsystemctl --user enable --now <unit>
What's the difference between oneshot and simple?
Oneshot services are for things like scripts that do a thing and exit. Simple is for basic services that intend to run for the lifetime of the system (or for user units, the lifetime of the user's session).