Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this script in a *.sh file to enable natural scrolling. I've added it to Startup Application.

xinput set-prop 11 268 -106 -106
nautilus -q && nautilus -n

The problem is, whenever I login, the last command (nautilus -n) won't run -which is annoying because I can't use the Super button to open Dash- and I have to run nautilus manually. What's wrong?


I have tested my script above on terminal line-by-line, and it works fine. The problems only appear when I run it from .sh file.

nautilus -q && touch $HOME/Desktop/reported-success.txt give me the txt file,

and the result of nautilus -q && nautilus -n &> $HOME/nautilus-output.log is :

Initializing nautilus-open-terminal extension
Initializing nautilus-image-converter extension
Initializing nautilus-dropbox 1.4.0
share|improve this question
Pardon me for asking, but just for the record: You did end the script with a linefeed/enter character or an empty line did you ? (If not, then the last command won't be executed.) – thom Apr 4 '13 at 3:46
No I didn't. Just an additional line or empty space didn't work either. But you're right, I changed the last line to nautilus -q && nautilus -n &&[enter], and it works, thanks alot. How do I make your comment as an answer @thom ? – Nur Apr 4 '13 at 11:13
@Nur: s/he'll have to do that her/himself. It's a very subtle thing indeed and a good point. It's something that wouldn't be visible here with the code formatting. – 0xC0000022L Apr 4 '13 at 17:10
@0xC0000022L Then, what should I do with this question? – Nur Apr 4 '13 at 17:25
@Nur: simply wait for thom to write an answer. I can also edit it into my answer if you prefer that. The possibility had crossed my mind initially, but I had discounted it (wrongly, it seems). – 0xC0000022L Apr 4 '13 at 17:29
up vote 0 down vote accepted

End the script with a linefeed/enter character or an empty line
or else the last command won't be executed.

share|improve this answer

Well from the script that means that nautilus -q returned a non-zero exit code. Hence the && evaluates to false and nautilus -n doesn't get executed.

You tell it: run nautilus -n if nautilus -q succeeded. The definition of success is an exit code of 0 in the shell.

Use ; instead of && to do it unconditionally or use a small wrapper script to translate the possible return codes that you want to accept as "success" into 0.

Another method to tear down running nautilus instances is obviously to use pkill this way:

pkill -u $(whoami) ^nautilus

You may want to specify a particular signal (pkill -SIGNALNAME -u ...), but I found no documentation on which signals nautilus reacts to.

The above command kills all instances of nautilus running as you (the whoami).

Use this to figure out what the first command (nautilus -q) returned:

nautilus -q || echo "exit code: $?"

What do you see? If it's not 0 then this is clearly the problem just the way the script logic suggests.

share|improve this answer
Addressing just the first part of this answer (the part that is an answer, whereas the second part is purely a request for information): This is probably not a very good solution, because the goal is to successfully restart Nautilus so that the changes made by the xinput command are applied. – Eliah Kagan Apr 3 '13 at 18:07
@EliahKagan: I see. I use Ubuntu as terminal-only, so I had to look up nautilus -q anyway. Let me address this. – 0xC0000022L Apr 3 '13 at 18:09
@0xC0000022L no output from nautilus -q || echo "exit code: $?", it just quit nautilus as usual, and I have to run nautilus manually again. And changing && with ; didn't work either. – Nur Apr 3 '13 at 18:23
@Nur: what about (the last line) as (nautilus -q || pkill -u $(whoami) ^nautilus || true) && (sleep 2; nautilus -n)? – 0xC0000022L Apr 3 '13 at 18:36
@0xC0000022L The same. Works in terminal. Works in separate (another) .sh file. But didn't work on my script. – Nur Apr 3 '13 at 19:15

Your Answer


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.