[April 06] Volumio (2.390-2018-03-27) ROCK64 | [April 06] Q4OS (2.4-r3) PINE A64(+) Pinebook | [Jan 06] Arch Linux (20171225-1) PINE A64(+) Pinebook A64-LTS/SOPINE | [Jan 04] Linux (0.5.15-136) ROCK64 | [Jan 04] Android (20171204) ROCK64 | [Dec 22] Stretch Mate (0.5.15-136-20171222) ROCK64 | [Dec 21] openHAB 2 (v1.4) PINE A64(+)

Project Inspiration | Get Started | IRC Logs | Forum Rules/Policy


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
Reply
#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
Reply
#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...
Reply
#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:
[email protected]:/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...
Reply
#15
Or add your user to the group "input"?
Reply
#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.
  If you manage to click this link you'll join in the IRC channel
Reply
#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.
Reply
#18
i, too am using this.
made a few tiny mods, see my here: http://dt.iki.fi/pbhacks/
Reply
#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'
Reply
#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)
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Disable touchpad tap to click? colin.faulkingham 15 968 08-04-2017, 09:36 PM
Last Post: MarkHaysHarris777
Sad touchpad edges scrolling kurai021 11 634 07-09-2017, 05:56 PM
Last Post: Luke

Forum Jump:


Users browsing this thread: 1 Guest(s)