10-18-2017, 03:27 PM
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:
paul ALL=(ALL)NOPASSWD:/usr/bin/python3 /usr/local/bin/touchpadsleep.py
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
- 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.
- 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.
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>
- 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