Gnome Shell: Running shell script after session starts?

You can use the program gnome-session-properties. Just execute it from your shell prompt (gnome-terminal):

$ gnome-session-properties

This will open a GUI where you can configure (i.e., add, edit, remove, enable and disable) startup programs.

Nice and easy. Enjoy.

Update: As noted by don_crissti (thanks) in the comments below, the gnome-session-properties startup programs functionality has migrated to gnome-tweak-tool since Gnome 3.12 (which btw is a great tool, but a little messier as it concentrates just too many functions). So, for versions 3.12 and above, this is the new place to look.

OBS: And btw, using this method, you don't need to create a .desktop file, you can simply specify the command line of the /home/neko/bin/auto_stuff.sh script you created (or any other script or command you want).


In .desktop files the case is significant. The following template works under Fedora 27 with GNOME shell (i.e. the Exec= value is executed during session start):

[Desktop Entry]
Encoding=UTF-8
Exec=/path/to/myscript arg1
Name=myscript
Comment=script some stuff
Terminal=false
OnlyShowIn=GNOME
Type=Application
StartupNotify=false
X-GNOME-Autostart-enabled=true

(to be stored as $HOME/.config/autostart/myscript.desktop)

The main difference: you used the key X-Gnome-Autostart= in your example.

Double check if your script /path/to/myscript is executable, i.e. if it has the executable permission bit(s) set.

The OnlyShowIn= is perhaps not significant for the autostart functionality, but I haven't tested it without it. You can list multiple desktop environments like this: OnlyShowIn=GNOME;LXDE;Unity; Consult the XDG_CURRENT_DESKTOP environment variable to verify correct values.

If you want to check whether your script prints any error messages you can check journalctl --user, i.e. the session journal.