I want to run a simple bash script automatically when I log in. For example

echo "start spotify"
gnome-terminal -e spotify --title spotify

When I run this command, one gnome-terminal shows up and spotify show up. I also want the gnome-terminal to popup "hidden" in a different virtual desktop. (one of the other four virtual desktops you can choose from taskbar)

I tried to add this to /home/me/.bash_login or something, but that didn't work..

  • You should use .bashrc or .profile. However, that's not good for starting programs on graphical login. There is an application for configuring startup applications. – Olli Mar 1 '11 at 14:43
  • @Olli, that starts it every time you open a Terminal window :) – Stefano Palazzo Mar 1 '11 at 15:05
  • @Stefano: or when you login from console, or over ssh. Whenever your shell is started. That's why I said "that's not good..." – Olli Mar 1 '11 at 16:31

Go to System → Preferences → Startup Applications, then click Add. Under Command just enter spotify, instead of the script. There's no need to start a terminal for it.

screenshot, startup application preferences

If you need the output, you can change your script:

echo "start spotify"
spotify > /home/username/spotify.log

and set it as the command, rather than Spotify itself.

Make sure the script is executable by opening the file's properties, going to permissions and setting "Allow executing file as program".

  • There might be multiple reasons for terminal. For example debug messages. – Olli Mar 1 '11 at 16:32
  • @Olli, Thank you, I've edited my answer accordingly. This seems to me like the proper solution. – Stefano Palazzo Mar 1 '11 at 16:53
  • yes, definitely. And of course you should use ~ instead of static path, so it'll work with any user :) – Olli Mar 1 '11 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.