3

Ubuntu Version: 22.04.1 LTS Hey! I'm trying to run startup.sh located in /root/startup.sh on startup. This is the content of the file:

synclient VertScrollDelta=-100
synclient CoastingFriction=35
synclient MinSpeed=0.05
synclient MaxSpeed=0.7
echo "All went according to plan..."

when I run the file manually using sudo /root/startup.sh then all goes according to plan, but after I wrote the following line in the thing that opens when you type crontab -e:

@reboot root sh /root/startup.sh >/dev/null 2>&1

and restarted my computer, nothing happened.I tried using this answer here, with the comment what you have to do on ubuntu.

Does anybody know how to fix this?

Logs:

Jan 17 11:04:10 sexy-cat-girl-computer CRON[1015]: (originalusernamelol) CMD (root sh /root/startup.sh >/dev/null 2>&1)

and with only @reboot root sh /root/startup.sh:

Jan 17 11:01:34 sexy-cat-girl-computer CRON[1026]: (originalusernamelol) CMD (root sh /root/startup.sh)
Jan 17 11:01:34 sexy-cat-girl-computer CRON[976]: (CRON) info (No MTA installed, discarding output)

I think discarding output isn't bad, right?

User1986
  • 321
  • How do you know "nothing happend" ? From my point of view everything looks as it should. The script is beeing executed on reboot. – Marco Jan 17 '23 at 10:37
  • This script is supposed to fix my light-speed touchpad, caused by awful default settings. If I run the script manually, it fixes it until rebooted. If instead I reboot, the settings go to default, instead of being changed by the script. I can confirm this by using synclient -l and seeing that all the variables are not what I wanted them to be in the script (for example MinSpeed=0.05, but its the default setting of MinSpeed=1). Do you know what might be causing this? – User1986 Jan 17 '23 at 11:26
  • 1
    Don't ask for something else than you try to solve! You asked "why is this stript not execured", but you wanted to solve a problem with your touchpad. – Marco Jan 17 '23 at 14:49
  • Marco... I already solved the problem with my touchpad. The solution is this script. Anything else I tried to solve the touchpad problem, including asking about the touchpad problem several times, has not solved the touchpad problem, or made the touchpad problem better. The touchpad problem is dangerous. When I asked the oracle about it, it told me to use the syncclient function, and that worked. – User1986 Jan 17 '23 at 15:22
  • 1
    You don't need the username (root) inside a regular crontab, that's just for the systemwide /etc/crontab (in fact it's an error - you can see from the log message CMD (root sh /root/startup.sh) that it's interpreting root as a command) – steeldriver Jan 17 '23 at 17:26

2 Answers2

5

Your commands to manipulate the touchpad's settings require an X server user session already running which is not the case during boot nor for the root user on Ubuntu.

The best way to run such a script is to save it under your regular user e.g. in your home directory and run it as a startup application ... or you can just nest all the commands in a sh command string like so:

sh -c 'sleep 10; synclient VertScrollDelta=-100; synclient CoastingFriction=35; synclient MinSpeed=0.05; synclient MaxSpeed=0.7'

and run it as a startup application i.e. like this example ... The sleep 10 call might be needed to allow the session fully load for ten seconds(you can shorten it if your desktop loads quicker to e.g. three seconds i.e. sleep 3 instead) before the commands are run.

Raffa
  • 32,237
0

You execute the command as the root user, not your regular user account. Tis probably has the effect that the configuration is performed for the root-user. Try to use your touchpad as the root user and it will probably work. Or change the line in the crontab to reflect and use the normal user account. E.g.: @reboot [insertyourordinaryusernamehere] sh /root/startup.sh >/dev/null 2>&1

Level9
  • 347