How to autostart script on Gnome 40 Wayland session launch?

I used to be able to have a script in ~/Documents/scripts/, that’s run from a Desktop file in ~/.config/autostart/startup.desktop, and then add that Desktop entry in the Startup Apps of the Gnome Tweaks app.

now, I can’t find my Desktop entry in the Startup Apps of the Gnome Tweaks app, and I also can’t run gnome-session-properties. Since this new issue I changed computers and I’m now on Gnome 40 and Wayland. The previous computer was set up with Gnome 3.36 I think, was updated to Gnome 40 later, and was using Xorg

I saw this thread Autostart shell script under Gnome with wayland that talks about using a user service, and I like the idea of using a systemd service, but I have no idea how I would do that.

here’s my ~/.config/autostart/startup.desktop:

[Desktop Entry]
Name=Startup script
GenericName=A script that runs at Gnome startup
Comment=Runs the script in Exec path

here’s my ~/.config/systemd/user/startup.service`:

Description=Auto start script at Gnome startup



Paths in systemd service files must be absolute:


It should complain about that in your journal.

Don’t forget to run systemctl --user daemon-reload after changing the file.
Enable the service with:
systemctl --user enable startup.service

1 Like

Are you telling us how or asking us for help? Please edit your post title accordingly.

1 Like

I added a question mark, I’m asking how to do something. It’s true that English is weird like that, where intonation only drives the meaning of a question.

“How do I” sounds super weird though, it puts the focus on me, nobody cares about me, what’s important is the thing I want to do and that maybe others might want to do to. Especially if they later search for something similar, they’ll probably search for something like “how to do X” rather than “how do I do X” or “how does one do X”

So it’s a question, and when it’s solved it becomes a tutorial. Also, wouldn’t a tutorial have a better place in another category than Support ? I’m not sure if it’s even ambiguous. If it’s really an actual issue that people misunderstand questions as tutorials, it would seem better to have a flair, or just title the question as “Question: How to … ?”

That worked thanks, now I have only the service and the script, and I removed the desktop file.

I was trying to run the service as a system script, I think, and it was complaining about the service not existing instead of giving me proper errors. Running the script as a user works well, though.

I imagine now the script runs when I log in, right ? Regardless of if gnome starts or not

For that, you should check the logind man pages. Usually, it starts when you login but you can also set it to start at boot. That’s up to you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.