1

I want to run a script that changes the mapping of my keyboard from the startup applications. The script is in my home folder and it has permissions 755. I've created a new entry in System -> Preferences -> Startup Applications and tried the following commands:

/bin/bash /home/myuser/myscript.sh
/sbin/sh /home/myuser/myscript.sh
/home/myuser/myscript.sh

None of them worked. The same commands work fine when I run them from a terminal manually.

I know of other ways to run a script at startup, but I want to know why is this method not working for me.

  • 1
    edit your question and add your script. – A.B. Jul 5 '15 at 9:17
  • @A.B. my particular script is not relevant to the question. I've already explained that it's a keyboard mapping. – Katu Jul 5 '15 at 9:38
  • 2
    What is relevant and what is not, you can leave the one who should answer the question like. – A.B. Jul 5 '15 at 10:04
3

Startup scripts, related to keyboard- or touchpad settings, or include wmctrl or xrandr commands often need "a little break" before running. If they run too early, before the desktop is fully loaded, they either break or "miss their target".

To solve that, you need to add:

/bin/bash -c "sleep 10 && /home/myuser/myscript.sh"

to your startup applications. Possibly you need to play a little with the sleep 10 value to optimize.

Note

Probably the script exists of only one or two commands, you could include them in your startup command, with the same syntax. That way you do not need a separate script.

  • 10 seconds delay to change the keyboard setup? o_O ;) – A.B. Jul 5 '15 at 9:20
  • @A.B. Yes, true. I am not sure what you mean? See my explanation. – Jacob Vlijm Jul 5 '15 at 9:30
  • Seems to work +1 =) – A.B. Jul 5 '15 at 10:07
  • 1
    Sure. In fact it is not mine own idea. I've found it few years ago on some forum. I use it in my conky startup script since then. – user128285 Jul 5 '15 at 13:14
  • 1
    The solution suggested by @user128285 didn't work for me. I'm using unity with ubuntu 15.04. Sleeping for 5 seconds works fine. – Katu Jul 5 '15 at 13: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.