Startup script doesn't launch on 18.04

Asked by Bryan on 2018-06-04

I have a .sh file that I would run on ubuntu 16.04 that calibrated my Tablet Monitor. It worked perfectly fine, but like many things, upgrading to 18.04 made that script stop running automatically on startup. The file is executable and I've added it using the "startup applications" app. Per a suggestion on another person's thread, I tried adding 'sh' to the beginning of the filepath, that also didn't work.

Any help would be appreciated. Thanks.

Here's my script below. the filename is xinput.sh:

#!/bin/bash

xinput set-prop 16 --type=float "Coordinate Transformation Matrix" 0.5 0 0 0 1 0 0 0 1

xinput set-button-map 9 1 3 2

----

And here's a screencap of my 'startup application' setup.

https://i.stack.imgur.com/ZQxwx.png

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
2018-06-05
Last reply:
2018-06-21

Does it need to run as root?

If you have the shebang on the first line, you don't need "sh" in the startup item.

Did you also run:

chmod +x ~/xinput.sh

If you add a line to write to /tmp in a file you can check the script is being called

Bryan (forleafe) said : #3

no it doesn't need and special permissions or anything. I tried chmod to no avail.

Can you tell me the exact line to add to the script that involves /tmp, as well as how to check if it's being called? Sorry, I just need this step a bit more detailed.

Just after the shebang add:

echo "it ran" > /tmp/result.txt

Add the below line as the last line:

gedit /tmp/result.txt

Reboot, log in and test. What is the output of:

ls -la ~/xinput.sh

Thanks

Bryan (forleafe) said : #5

Okay so I added the lines to the xinput.sh file and as soon as I logged in, a gedit window popped up with the text "it ran"

Testing the output of your command gave me this:

-rwxrwxr-x 1 bryan bryan 188 Jun 4 17:32 /home/bryan/xinput.sh

So it would seem the script is running. The real question is, why it's not working. It's strange. As soon as I'm all logged in, I can manually run that script and it'll work. But running at startup it's not working. Why would that be?

OK so we know the script is being executed.
This is good.
Try a small sleep command in the script. Remove the lines we added earlier.

After the shebang, add:

sleep 10

Save and reboot to test

Bryan (forleafe) said : #7

Like this? If so, yeah I tried it and nothing happened.

#!/bin/bash
sleep 10
xinput set-prop 16 --type=float "Coordinate Transformation Matrix" 0.5 0 0 0 1 0 0 0 1

xinput set-button-map 9 1 3 2

Try:

#!/bin/bash
sleep 10
DISPLAY=:0.0 xinput set-prop 16 --type=float "Coordinate Transformation Matrix" 0.5 0 0 0 1 0 0 0 1

DISPLAY=:0.0 xinput set-button-map 9 1 3 2

Bryan (forleafe) said : #9

Unfortunately it didn't work. :/ It's so weird. When I log in the code just doesn't work. But as soon as I'm i'm actually finished logging in and can see the desktop, all I have to do is open a terminal and run it by typing:

./xinput.sh

and immediately it'll run and work properly. I don't know why running it at startup should be any different.

Launchpad Janitor (janitor) said : #10

This question was expired because it remained in the 'Open' state without activity for the last 15 days.