Help with Touchpad script for cron and crontab entry

Help with Touchpad script for cron and crontab entry

It works running manually from the Desktop but only for the current session.
But setting up a cron and crontab to run at reboot doesn’t work.

What am I doing wrong here?

I didn’t try setting them both to run at boot.
When it didn’t work for /usr/local/bin, I used a timeshift restore and tried for /usr/local/sbin.

I ran…
$ xinput list

Terminal printed…
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech M185/M225 id=9 [slave pointer (2)]
⎜ ↳ ELAN071A:00 04F3:30FD Touchpad id=10 [slave pointer (2)]
⎜ ↳ ELAN071A:00 04F3:30FD Mouse id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
↳ Wireless hotkeys id=13 [slave keyboard (3)]
↳ HP WMI hotkeys id=14 [slave keyboard (3)]
↳ Logitech M185/M225 id=15 [slave keyboard (3)]

I created the script…

#!/bin/bash

/usr/bin/xinput --disable 10

I put the script in both directories…

$ sudo /usr/bin/featherpad /usr/local/bin/Touchpad-Disable.sh

$ sudo /usr/bin/featherpad /usr/local/sbin/Touchpad-Disable.sh

I set the permissions for both…

$ sudo chmod a+x /usr/local/bin/Touchpad-Disable.sh

$ sudo chmod a+x /usr/local/sbin/Touchpad-Disable.sh

I set the crontab entries for both…

$ sudo crontab -e
@reboot /path/to/script

$ crontab -e
@reboot /path/to/script

It’s probably that the devices are enumerated differently with every boot. Instead of the device number, use the device name and optionally, the device type to help with ambiguity. Here’s a real world example to help you understand what I mean by that:

wxl@amorphous:~$ xinput
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Adafruit KB2040 Keyboard                  id=10   [slave  pointer  (2)]
⎜   ↳ Adafruit KB2040 Mouse                     id=11   [slave  pointer  (2)]
⎜   ↳ Qwertykeys qk60 Mouse                     id=13   [slave  pointer  (2)]
⎜   ↳ Qwertykeys qk60 Consumer Control          id=15   [slave  pointer  (2)]
⎜   ↳ E-Signal USB Gaming Mouse                 id=18   [slave  pointer  (2)]
⎜   ↳ E-Signal USB Gaming Mouse Keyboard        id=19   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ Qwertykeys qk60                           id=12   [slave  keyboard (3)]
    ↳ Qwertykeys qk60 System Control            id=14   [slave  keyboard (3)]
    ↳ Qwertykeys qk60 Keyboard                  id=16   [slave  keyboard (3)]
    ↳ Apple Computer, Inc. IR Receiver          id=17   [slave  keyboard (3)]
    ↳ Adafruit KB2040 Keyboard                  id=20   [slave  keyboard (3)]
    ↳ Qwertykeys qk60 Consumer Control          id=21   [slave  keyboard (3)]
    ↳ E-Signal USB Gaming Mouse Keyboard        id=22   [slave  keyboard (3)]
wxl@amorphous:~$ xinput | grep "Adafruit KB2040 Keyboard"
⎜   ↳ Adafruit KB2040 Keyboard                  id=10   [slave  pointer  (2)]
    ↳ Adafruit KB2040 Keyboard                  id=20   [slave  keyboard (3)]
wxl@amorphous:~$ xinput list "Adafruit KB2040 Keyboard"
Warning: There are multiple devices matching 'Adafruit KB2040 Keyboard'.
To ensure the correct one is selected, please use the device ID, or prefix the
device name with 'pointer:' or 'keyboard:' as appropriate.

unable to find device Adafruit KB2040 Keyboard
wxl@amorphous:~$ xinput list keyboard:"Adafruit KB2040 Keyboard"
Adafruit KB2040 Keyboard                        id=20   [slave  keyboard (3)]
        Reporting 1 classes:
                Class originated from: 20. Type: XIKeyClass
                Keycodes supported: 248

I would rather setup a shortcut key so that the recipient can toggle the touchpad when she needs it.

There’s no option in hp’s BIOS for it.

She has no experience whatsoever with linux, and I’m trying to set it up for as easy for her to use.

Windows 11 messed her up so bad she got mad and told me she want’s something else.
The updates kept changing her settings to how Microsoft wanted those settings.

I’m not sure this works exactly the same with every device but if you disable a device it seems to show a different output:

∼ Adafruit KB2040 Keyboard                      id=20   [floating slave]

Note the first character. It means it’s out of the tree. It’s also now “floating.”

So I think you could do something like this:

#!/usr/bin/env bash

mydevice="ELAN071A:00 04F3:30FD Touchpad"

# check if device is disabled
if [ "$(xinput list --short "$mydevice" | grep floating)" ]; then
   xinput enable "$mydevice"
else
   xinput disable "$mydevice"
fi

Warning: if the device has the exact same name but both as a pointer and as a keyboard as in my “Adafruit KB2040 Keyboard” this becomes infinitely difficult. Though I’ve showed you the way to distinguish between them above, that doesn’t work when the device is disabled because at that point, it’s neither pointer nor keyboard.

Oh, then set up a shortcut in your shortcut manager. Since I seem to remember you’re on Lubuntu, that means lxqt-config-globalkeys.