Proof of concept script to disable the touchpad while typing
#17
Firstly, this is a brilliant script, very useful.  I wish all laptops could run it! (That's a project for the future).

Secondly, great idea to try to get it to run automatically at startup.  I've struggled with this, I have to say, but have now got it working.  I am relatively new to Ubuntu so forgive me if I have got any of this wrong, or write anything too obvious.  This is assuming you have already  got touchpadsleep.py  to run properly.

There are 2 stages:

1 Set up a startup program by:
  • go to System>Preferences>Personal>Startup Applications in the menu at the top of the screen
  • you will now see a window showing all the existing startup applications, and allowing you to add new ones (button marked +ADD)
  • this window has 3 boxes t type in:
  • Name - you can put anything you like in here- it's just the title of the startup (I called it MouseCalmer)
  • Command - this is the important bit - I put   sudo python3 /usr/local/bin/touchpadsleep.py
  • Comment - anything you want - I described what the application is doing uses touchpadsleep to pause mouse on keystroke
  • Press Save
A few of things to note -
  • I've used Python 3
  • I saved the python script as touchpadsleep.py in /usr/local/bin
  • This won't work yet! Because the command 'sudo' will want to ask for your password and becuse it is running automatically, you can't type it in.
  • There is a way to allow only python3 to run only touchpadsleep.py without a password.  You do this by editing a special file called sudoers.  If not done correctly, this can break your installation of Ubuntu (or any linux) but there is a safe way to do it.
2 Add an entry to sudoers to allow python3 and touchpadsleep.py to run without a password.
  • Open a terminal by pressing <ctrl><alt><t>
  • in the terminal, type sudo visudo - visudo is a special editor which will protect against accidental errors in sudoers and only save a valid version
  • Add the following lines near the end of the file, after any other similar lines.
            # Allow python to run touchsleep as sudo without password
             paul ALL=(ALL)NOPASSWD:/usr/bin/python3 /usr/local/bin/touchpadsleep.py
  • Press <ctrl><X>
  • Answer Y when sked to save
  • Don't change the file name visudo wants to save (/etc/sudoers.tmp)  - just press <enter>
More things to note
  • in sudoers, any line starting with # does nothing and is just for documentation
  • paul is my username, as you might expect, just substitute your own when you do this
  • I discovered this only works if the full paths to both python3 and touchpadsleep.py these may be different on your system
Touchpadsleep.py should run invisibly and automatically next time you restart the laptop.


Messages In This Thread
RE: Proof of concept script to disable the touchpad while typing - by Paul - 10-18-2017, 03:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to enable touchpad natural scrolling? plumlis 3 6,386 07-19-2020, 02:46 PM
Last Post: Martin Gruber
  Disable touchpad tap to click? colin.faulkingham 25 35,630 04-27-2020, 07:31 PM
Last Post: ab1jx
Sad touchpad edges scrolling kurai021 11 13,592 07-09-2017, 05:56 PM
Last Post: Luke

Forum Jump:


Users browsing this thread: 2 Guest(s)