In this thread Temporarily Disable Touchscreen I asked how could I disable my HP touchscreen. By trial and error, and using the command
I was able to identify which device was the touchscreen and by typing
xinput disable id
being the id the device's actual number, I can disable the touchscreen.
The problem is that I have to do this every time I turn on my pc. Furthermore, depending if I turn on my computer with the mouse or not, the touchscreen changes its id.
I want to write a script that disables the touchscreen automatically every time I turn on the laptop so I need to take this in account. In the script I wrote
cd /home/user/Desktop/touchscreen_ids xinput --list | grep "ELAN" | grep "slave pointer" > id.txt
(the first command goes to this particular folder and the second writes the following text in txt file
⎜ ↳ ELAN2514:00 04F3:2AF4 id=9 [slave pointer (2)]
). Then, still in the same script I wrote
sed -i 's/id=/\nid=/g' id.txt sed -i 's/\[/\n\[/g' id.txt cat id.txt | grep "id=" > iso_id.txt sed -i 's/id=//g' iso_id.txt touchscreen_id=$(cat iso_id.txt) xinput disable $touchscreen_id
This works well when I run the script. However, using the cron tab @reboot option, when I turn on the pc, it creates the txt files but they are empty and the touchscreen is enabled.
Do you guys have any clue about what's going on here? I am not very experienced with Linux or the command line, so please try to keep it simple.
Thank you in advance!
xinput list --id-only '<name-of-device>'should return it directly