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 wanted to run this at start-up because I like to play around with multiple DEs. When I run this script from a file it won't run Docky.

I have already changed the file permissions so that it is allowed to run as a program.

When I type exactly this into gnome-terminal it will run Docky if I am logged into gnome-classic. I wanted to run this script at startup so that Docky wouldn't start in Unity:

if [ $DESKTOP_SESSION == "gnome-classic" ] ; then docky ; fi

Any suggestions? I tried writing something like Firefox in the same file and it will start Firefox. So when I run the following script from a file...

cd /home/user/Desktop
mkdir ITRAN
if [ $DESKTOP_SESSION == "gnome-classic" ] ; then docky ; fi

It makes a new file on my desktop but won't run Docky even though if I simply copy the same code into a terminal window it runs...

With geirha's help, I changed the script. However, now docky launches no matter what DE I run, Unity or gnome-classic.

#!/bin/sh
if [ $DESKTOP_SESSION = "gnome-classic" ]; then
   docky
fi

I've also tried

$DESKTOP_SESSION = "gnome-classic"
$DESKTOP_SESSION = gnome-classic
"$DESKTOP_SESSION" = gnome-classic
"$DESKTOP_SESSION" = "gnome-classic"

to rule out the possibility that I had that part wrong.

share|improve this question
    
What file are you using to run the script, .profile, .bashrc, etc....? –  Shutupsquare Jun 27 '12 at 22:30
    
A .sh file I created in my home folder –  utsuro Jun 27 '12 at 22:51

2 Answers 2

up vote 4 down vote accepted

The [ command does not have a == operator. Bash allows it, but dash will cringe. The correct operator to use is =. The script you posted in your question does not have a shebang, so it likely gets run by sh. So:

#!/bin/sh
mkdir -p "$HOME/Desktop/ITRAN"
if [ "$DESKTOP_SESSION" = gnome-classic ]; then
    docky
fi

Anyway, if it fails, you'll likely find the error messages in ~/.xsession-errors, so look in there for clues.

share|improve this answer
    
Now it runs no matter what DE I run... –  utsuro Jun 27 '12 at 22:40
    
@utsuro, Well, it only runs docky if DESKTOP_SESSION contains gnome-classic, so I'd look into two things. 1. Check that you don't have any other scripts that run docky (like a previous attempt at this script). 2. Check that DESKTOP_SESSION actually gets set to different values for different DEs. (Using the default session (with unity) on my 12.04 install, DESKTOP_SESSION is set to ubuntu here) –  geirha Jun 27 '12 at 23:47
    
Yeah, I tested it first in gnome-classic and it launched and then, Docky made an entry in the start-up applications list -____- I though I disabled that... –  utsuro Jun 29 '12 at 1:14

Make sure your script starts with:

#!/bin/sh

Moreover, make sure your script is executable:

chmod a+x path/to/your/script.sh
share|improve this answer
    
In my post I said I had changed the permission –  utsuro Jun 27 '12 at 22:44

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.