8

I have a simple one line command which works perfectly in terminal, but does not work in the "Startup Applications" app thing.

The line of code is : xmodmap /home/seph/Code/Ubuntu\ Scripts/Xmodmap

It's not that much of a hassle to copy it from "Startup Applications" and paste it into terminal, but I don't really get why it isn't working. I followed someone else's instructions to do it in the first place, so maybe I did something wrong? In any case, wouldn't it be the obvious and logical assumption that it just types whatever you put in it into Terminal?

  • That's exact same problem that I had! +1 – jedi May 24 at 21:13
12

Commands, especially those related to keyboard, mouse and touchpad settings, or xrandr commands, often need the desktop to be fully loaded. If you run them simply at log in (using Startup Applications), they often run too soon and break.

Therefore, you need to build- in a little break before the command should run. Use the following command instead to add to Startup Applications:

/bin/bash -c "sleep 15 && xmodmap /home/seph/Code/Ubuntu\ Scripts/Xmodmap"

Chooes Dash > Startup Applications > Add, and add the command.

That should do the trick.

  • That's what I thought. I wonder why the delay is needed though. X should be fully up and running by the login. I mean I know there's this issue, it's not the first time read about it, I just wonder why is that. – kos Dec 10 '15 at 7:06
  • 1
    @kos I suspect at a certain point, the local settings are applied, overruling the command on startup (since they pop up later). – Jacob Vlijm Dec 10 '15 at 7:07
  • 1
    Makes sense. I'll try to research this a bit, I'm mildly curious about that. – kos Dec 10 '15 at 7:11
  • 1
    @kos ...In other cases, it is the desktop, being not ready yet. I remember a bug in Dropbox, where the icon appeared on the left side (Unity) of the panel, could be fixed with the same trick. – Jacob Vlijm Dec 10 '15 at 7:13
  • 1
    this explains a lot. Almost every startup script I've really needed has had something to do with fixing the keyboard or mouse. I find it strange that this is not a use case which was planned around. – Seph Reed Dec 14 '15 at 17:54
0

Add this code snippet into a .conf file in ~/.config/upstart/:

start on startup
task
exec xmodmap /home/seph/Code/Ubuntu\ Scripts/Xmodmap
  • add it where? upstart is a folder. Should I make a new file? What kind of extension should it have? – Seph Reed Dec 10 '15 at 3:54
  • into a conf file in the folder. I've updated my answer. – Tung Tran Dec 10 '15 at 4:09
  • I tried this with exec xrandr --output DP-1 --brightness 0.85 but it had no effect. could it be that on startup is too soon? what event signifies that the unity desktop is ready? – Superole Aug 9 '17 at 12:03

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.