Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

#!/bin/bash
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..

share|improve this question
    
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

1 Answer 1

up vote 5 down vote accepted

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:

#!/bin/bash
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".

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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