Proof of concept script to disable the touchpad while typing
#11
it doesn't disable the password for your account--just for commands run with sudo. You can limit it so that only certain commands are run with no passwd. Lookie here https://askubuntu.com/questions/159007/h...a-password
#12
Thumbs Up 
Nice!  The combo of the commands in sudoers and adding it to startup indeed starts it nicely in the background upon startup/login Smile
#13
I don't run the script with sudo, shouldn't be needed, as user you should be able to do what it needs to do...
#14
(08-27-2017, 07:56 AM)daid Wrote: I don't run the script with sudo, shouldn't be needed, as user you should be able to do what it needs to do...

Code:
combs@pinebook:/usr/local/bin$ python3 trackpadsleep.py
Unable to connect to X server
Traceback (most recent call last):
 File "trackpadsleep.py", line 372, in <module>
   TouchpadHack().inputReadThread()
 File "trackpadsleep.py", line 332, in inputReadThread
   f = open(event_path, "rb")
PermissionError: [Errno 13] Permission denied: '/dev/input/event0'

Could probably just change perms on that, come to think of it...
#15
Or add your user to the group "input"?
#16
(08-28-2017, 02:28 AM)daid Wrote: Or add your user to the group "input"?

Tried that. I can now run the script without elevated privilages from terminal, but it still doesn't work on startup.
You can find me on IRC, Discord and Twitter


#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.
#18
i, too am using this.
made a few tiny mods, see my here: http://dt.iki.fi/pbhacks/
#19
Has anyone gotten this script to work in the Armbian OS for Pinebook? I get the following errors when I try to use it:

Code:
Traceback (most recent call last):
 File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
   self.run()
 File "/usr/lib/python3.5/threading.py", line 862, in run
   self._target(*self._args, **self._kwargs)
 File "touchpadsleep.py", line 312, in timeoutThread
   device_number = self.findXInputDeviceNumber()
 File "touchpadsleep.py", line 303, in findXInputDeviceNumber
   res = subprocess.run(["/usr/bin/xinput", "list"], stdout=subprocess.PIPE).stdout
 File "/usr/lib/python3.5/subprocess.py", line 693, in run
   with Popen(*popenargs, **kwargs) as process:
 File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
   restore_signals, start_new_session)
 File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
   raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/xinput'
#20
(11-23-2017, 08:51 PM)southern.cross Wrote: Has anyone gotten this script to work in the Armbian OS for Pinebook? I get the following errors when I try to use it:

Code:
Traceback (most recent call last):
 File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
   self.run()
 File "/usr/lib/python3.5/threading.py", line 862, in run
   self._target(*self._args, **self._kwargs)
 File "touchpadsleep.py", line 312, in timeoutThread
   device_number = self.findXInputDeviceNumber()
 File "touchpadsleep.py", line 303, in findXInputDeviceNumber
   res = subprocess.run(["/usr/bin/xinput", "list"], stdout=subprocess.PIPE).stdout
 File "/usr/lib/python3.5/subprocess.py", line 693, in run
   with Popen(*popenargs, **kwargs) as process:
 File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
   restore_signals, start_new_session)
 File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
   raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/xinput'

Looks like xinput is not installed:

https://packages.ubuntu.com/search?keywo...ection=all

After a:

sudo apt-get install xinput

it ill probaby work? (works on my pinebook, Armbian 5.34)


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

Forum Jump:


Users browsing this thread: 4 Guest(s)