Solved Start-up script not working

Solved issue

Gallerilt

New Member
Joined
Sep 6, 2023
Messages
22
Reaction score
1
Credits
206
I have changed from Ubuntu to debian/LXDE; glad to. I don`t want my touchpad to be activated at startup, and have made a script to disable it at startup/boot: "xinput disable 'SynPS/2 Synaptics TouchPad'". I can start the script manually, and it works, but not at boot.
I have tried all 3 methods here: https://www.heatware.net/linux-tips/run-execute-script-on-linux-startup/
I must be overlooking something, but what? Some clues?
 


I wish I could tell you immediately how to do this, but unfortunately I can't! Puppy Linux does things rather differently.....and one unique Puppy feature is the inclusion of a directory within the user directory - which for us is /root - simply called 'StartUp'.

Anything placed within this directory is automatically executed at boot time. Easy-peasy.

I suspect you'll be looking at placing your script somewhere like /etc/init.d. This also works for us in Puppyland, but the 'StartUp' directory just makes life so much simpler...

Hang about for a bit, and be patient. Most here run standard, mainstream distros and will be able to offer concrete advice on this. We'll get you sorted. Nothing's impossible, and this is quite a usual request.


Mike. ;)
 
On some models you can disable the touchpad in the BIOS.
Have a look at the touchpad.log, journal and Xorg.logs, they may reveal something.

Is the script running with root privileges?

Get the touchpads id number and then you may be able to disable it that way. See the link below.
With Linux there is more than one way to enable or disable things.

How to Enable/Disable Touchpad in Linux
 
Try using one shot in your systemd unit, something like this.
Code:
[Unit]
Description=xinput disable 'SynPS/2 Synaptics TouchPad

[Service]
Type=oneshot
ExecStart=/usr/loca/bin/myscript.sh

[Install]   
WantedBy=multi-user.target
If it need to needs to run as root place it under: /etc/systemd/system
If it needs to run as user place it under: $HOME/.config/systemd/user

If it needs to run as root run the following.
Code:
sudo systemctl daemon-reload
sudo systemctl enable myscript.service
If it needs to run as user run the following.
Code:
systemctl --user daemon-reload
systemctl --user enable myscript.service
 
I have tried to run my script from cron @reboot, but it will not run. I have added a touch command to my cronjob, to test, and it works - but not my script. I have added my script in $PATH, but without success. I have tried to add to my @reboot cronjob: xinput disable 'SynPS/2 Synaptics TouchPad', but then my cronjob is not working at all; the touch command is not making av new file - it follows after the xinput in crontab.
Maybe some syntax error in the xinput disable 'SynPS/2 Synaptics TouchPad' - line? Maybe som kind of quotation marks around the command?
Here is my cron job not working at all:
@reboot sleep 10 && xinput disable 'SynPS/2 Synaptics TouchPad' && touch /home/helge/Skrivebord/test.txt
This makes a new file, but not running my script:
@reboot sleep 10 && /usr/bin/myscript.sh && touch /home/helge/Skrivebord/test.txt
Some cron experts around?
 
I have tried to run my script from cron @reboot, but it will not run. I have added a touch command to my cronjob, to test, and it works - but not my script. I have added my script in $PATH, but without success. I have tried to add to my @reboot cronjob: xinput disable 'SynPS/2 Synaptics TouchPad', but then my cronjob is not working at all; the touch command is not making av new file - it follows after the xinput in crontab.
Maybe some syntax error in the xinput disable 'SynPS/2 Synaptics TouchPad' - line? Maybe som kind of quotation marks around the command?
Here is my cron job not working at all:
@reboot sleep 10 && xinput disable 'SynPS/2 Synaptics TouchPad' && touch /home/helge/Skrivebord/test.txt
This makes a new file, but not running my script:
@reboot sleep 10 && /usr/bin/myscript.sh && touch /home/helge/Skrivebord/test.txt
Some cron experts around?
In debian, systemd timers can replace cron. Basically, one writes a systemd script, and a timer script. The timer script calls the systemd script at the configured time, which in this case would be at boot.

However, this command to disable the touchpad may not need to be in cron, or in a systemd timer arrangement at all, since a systemd unit script such as mentioned by @f33dm3bits in post #5 would be sufficient when enabled to run as a oneshot.

There is the older "traditional" means of running a command using the /etc/rc.local file. It's simplicity might be attractive. One would write the command one wants to run in the /etc/rc.local file, perhaps making it a script, creating the file if it doesn't exist. Then one gives the file execute permissions, e.g.
chmod 755 /etc/rc.local
Systemd will then run the command at the end of the booting process each time the machine is booted. That's all there is to it. If the command works manually, as mentioned in post #1, it would normally work just the same in /etc/rc.local. Systemd doesn't need to enable it since it's a static unit.
 
Yah, osprey's hit the nail on the head, as usual! We have it ordered slightly differently within Puppy, but not by much.....the rc.local file lives inside /etc/rc.d for us, hence /etc/rc.d/rc.local is its location.

It still performs the same functions, however (perhaps it's like this because we use a modified sysvinit; maybe newer boot-loaders/init systems look for it AT /etc/rc.local.....I can't say).

Unlike many files within the init system, this one is intended to be user-editable (most are generated by other functions, with appended warnings NOT to modify them). This one, you're fine to modify/edit it/add stuff as & when necessary, because that's what it was always intended for.....a way to modify the init system via direct user input, as opposed to being generated by the system itself, and always executed immediately the boot process has finished.

@Gallerilt :-

Would it be asking too much for you to give us a direct copy/paste of your startup script, so that we can have a look through the syntax for you? As you've probably surmised by now, if Linux scripts aren't written exactly right, they will NOT run.......it only takes a space where there shouldn't be one, or a '.' instead of a ',' or ';' (or vice versa), or an extra dash or tilde '~', etc. Bash is very sensitive to stuff like this, since it can completely change the entire context of a command along with what the system thinks you're asking it to do.....

You do need to constantly check, double-check AND "proof-read" with scripts. It's a habit that develops with experience, so don't feel bad about getting stuff wrong if you haven't done much scripting.....we all went through this learning phase!


Mike. ;)
 
Last edited:
My script is:

#!/bin/bash

# slå av touchpad ved oppstart

xinput disable 'SynPS/2 Synaptics TouchPad'

exit 0

It works from the terminal, but not when put into /etc/rc.local.
I don't have any /etc/rc.d, but /etc/rc0.d; rc1.d etc. There is among others K01 alsa-utils etc etc.
Would it help putting it in one of these?
 
This makes a new file, but not running my script:
@reboot sleep 10 && /usr/bin/myscript.sh && touch /home/helge/Skrivebord/test.txt
Some cron experts around?

Since you used the '&&' link to run the three commands in sequence, each depending upon the success of the ones before it, the touch command creating a new file implies strongly that myscript.sh is running and is succeeding in whatever it does.

I wonder if there's some issue within the script that's allowing it to run without doing what you need it to do -or- perhaps something later in the bootup process is undoing it (re-enabling the touchpad)?
 
If you're going to run a cron job I would suggest putting everything in a bash script and calling that instead of using multiple commands in your crontab file. What is your system runlevel when you call this systemd unit file? You need to use a proper systemd header in your script in /etc/init.d and make sure it returns zero.

Signed,

Matthew Campbell
 
My script is:

#!/bin/bash

# slå av touchpad ved oppstart

xinput disable 'SynPS/2 Synaptics TouchPad'

exit 0
You need to use "oneshot" in your systemd unit because default is "simple/forking" will expect it to be still running afterwards, otherwise it will see the process as "dead". Since your script is not setup to be running after you execute it once you should juse use "oneshot".
Code:
[Unit]
Description=A simple oneshot service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/disable_touchpad.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
 
Last edited:
Some strange thing: when I'm logging in to gnome DE the script/initd works. But not with LXDE, xfce or gnome classic. Something must be happening during logging in; after the boot process. But how to unravel this?
 
Some strange thing: when I'm logging in to gnome DE the script/initd works. But not with LXDE, xfce or gnome classic. Something must be happening during logging in; after the boot process. But how to unravel this?
One way to "unravel" the conundrum is to take a trial and error approach. That involves trying different things to hopefully find one configuration that works for you. What you have described is just that, but since it hasn't yielded what you'd like to end up with, what choice is there but to continue?

The following are some observations on the issue.

In post #1, you mention that you've tried all the three methods at:
https://www.heatware.net/linux-tips/run-execute-script-on-linux-startup/

There is a systemd service file described there, not unlike the suggestion of @f33dm3bits in post #5. It's described for ubuntu, and not for debian, but it would function the same on a debian systemd installation which is the one evidently running according to post #1.

Did you try that systemd method? If you did, and it failed, did you check the journal logs to see any information there about why it failed?

For debian, the above link suggests writing an init script to run from /etc/init.d/<script>. That script needs to be written according to a specific format, examples of which can be seen by inspecting some of the files already in that directory. The format is described in: man init-d-script.

Did you write such an init script, register it in the system and update with the update-rc.d command?

In relation to the actual commands that you used to disable the touchpad, it's worth noting that the man page shows some different, but equivalent commands. It may be worth trying the alternative command. It may seem odd that they would have any different outcome since they are described as equivalent. Nevertheless, sometimes odd and unpredictable outcomes happen.

The alternative command from the man page may be something like:
Code:
xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0

In relation to the script not working in lxde, did you use the lxde autostart facility? There's a description of the process in the answer sections here:

There are some more experiences described by users here which may reflect on this issue:

It's worth noting that the baeldung resource mentioned by @Alexzee in post #4, has different commands again for the same disabling process so it may be worth considering and trialing those.

It may seem like a lot of messing around to get where you want to be, but sometimes linux is like that for users who aren't that deeply familiar with all the software they use :).
 
Last edited:
want to mark it "solved".....
go back to your first post, select edit, to the left of the title is a dropdown box, select solved
 

Members online


Latest posts

Top