11

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?

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

2 Answers 2

17

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 login (using Startup Applications), they often run too soon and break.

Therefore, you need to introduce a little time break before your actual command runs. Use the following command instead to add to Startup Applications:

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

Open the dash → Startup Applications → Add, and add the command.

That should do the trick.

6
  • 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, 2015 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). Dec 10, 2015 at 7:07
  • 1
    Makes sense. I'll try to research this a bit, I'm mildly curious about that.
    – kos
    Dec 10, 2015 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. Dec 10, 2015 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, 2015 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
4
  • add it where? upstart is a folder. Should I make a new file? What kind of extension should it have?
    – Seph Reed
    Dec 10, 2015 at 3:54
  • into a conf file in the folder. I've updated my answer.
    – Tung Tran
    Dec 10, 2015 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, 2017 at 12:03
  • 1
    @Superole for me xrandr works when executed in ~/.profile
    – br4nnigan
    Aug 29, 2023 at 9:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .