this post was submitted on 17 May 2025
8 points (83.3% liked)

Arch Linux

8753 readers
1 users here now

The beloved lightweight distro

founded 5 years ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] jrgd@lemm.ee 19 points 4 weeks ago (1 children)

Create a systemd user unit that waits for the network-online.target.

A script something like:

[Unit]
Description=Startup script
Requires=network-online.target
After=network-online.target

[Service]
Type=oneshot # either simple or oneshot, but sounds like oneshot
ExecStart=/home/<user>/script.sh
RemainAfterExit=yes #if oneshot, otherwise no

[install]
WantedBy=default.target

Edit the template according to your needs and dump it into ~/.local/share/systemd/user/<unit>.service and enable it with systemctl --user enable --now <unit>

[–] MoLoPoLY@discuss.tchncs.de 3 points 4 weeks ago (1 children)

What's the difference between oneshot and simple?

[–] jrgd@lemm.ee 8 points 4 weeks ago (1 children)

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).

[–] MoLoPoLY@discuss.tchncs.de 2 points 4 weeks ago

Ahh ok. Since in this case the script should only run at start and then exit, I use oneshot. Many thx.