Touchpad disable script help

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
uggbootcity
Level 1
Level 1
Posts: 12
Joined: Fri Jun 29, 2007 8:37 pm
Location: Gold Coast, Australia

Touchpad disable script help

Post by uggbootcity »

Like so many laptop owners, erratic touchpad interference whilst typing drives me nuts! I use an external usb mouse and disable the touchpad totally.

I have a little script that I can run manually:

Code: Select all

#!/bin/sh
# Script to look for USB mouse and, if present, disable touchpad
# Can also be run to re-enable touchpad if usb mouse removed 

if lsusb | grep "Darfon"  ; then
    rmmod psmouse
else
    modprobe psmouse
fi
Of course, I have to run this as root, so password needs to be entered.

How can I run this automatically startup so I don't need the password?

Is this the best way of doing what i am trying to do? The touchpad does not use the synaptic driver, so synclient/gsynaptic type solutions don't work.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
900i
Level 6
Level 6
Posts: 1142
Joined: Sat Nov 18, 2006 9:30 am
Location: Wakefield, UK

Post by 900i »

This is basically how to run apps at startup, but I made the video for Beryl. The steps are the same, just input the name of your script.

http://www.900i.me.uk/Beryl.ogg

Edit: - You may have to change file permissions on your script?
Desktop Core i7 Linux Mint 21.1 / Laptop Dell Precision M6400 Linux Mint 21.1
User avatar
uggbootcity
Level 1
Level 1
Posts: 12
Joined: Fri Jun 29, 2007 8:37 pm
Location: Gold Coast, Australia

Post by uggbootcity »

Still does not work. The only whay it works is when I run it as root, so simply putting it in session manager will try and execute it as a normal user.

How do I run it automatically as root?

MV
antiquexray
Level 5
Level 5
Posts: 604
Joined: Sat Nov 18, 2006 6:04 pm
Location: Albert Lea Minnesota USA

Re: Touchpad disable script help

Post by antiquexray »

uggbootcity wrote:...erratic touchpad interference whilst typing drives me nuts...I have a little script that I can run manually...I have to run this as root...How can I run this automatically...
I'm feeling very comfortable with Mint, but still a noob with the linux command line. Since the touchpad makes me crazy as well, can you provide some detail instruction on how to make this script, or a least point me to a tutorial where I can learn it. Thanks.
User avatar
Boo
Level 7
Level 7
Posts: 1633
Joined: Mon Mar 26, 2007 7:48 am

Post by Boo »

the script can be run from /etc/rc.local at boot.

in the rc.local file put the full path to your script.
it will be run as root.

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
uggbootcity
Level 1
Level 1
Posts: 12
Joined: Fri Jun 29, 2007 8:37 pm
Location: Gold Coast, Australia

Post by uggbootcity »

Boo, Thanks for your help. Works perfectly!

AntiqueXRay, This is what i did to get this to work.

Needed to find out what the computer sees the usb mouse as, so used lsusb from terminal to list connected usb devices:

Code: Select all

:~$ lsusb
Bus 005 Device 001: ID 0000:0000  
Bus 002 Device 002: ID 08ca:2010 Aiptek International, Inc. Pocket CAM 3 Mega (webcam)
Bus 002 Device 001: ID 0000:0000  
Bus 001 Device 005: ID 03f0:3f11 Hewlett-Packard PSC-1315/PSC-1317
Bus 001 Device 004: ID 0d62:1000 Darfon Electronics Corp. 
Bus 001 Device 001: ID 0000:0000  
Bus 004 Device 001: ID 0000:0000  
Bus 003 Device 001: ID 0000:0000  
:~$ 
Unplug mouse try again to confirm that "Darfon" is my mouse.

Then created a text file called touchpadoff.sh

My thinking about the process was:

Pipe the output of "lsusb" into the "grep" command to test for the "Darfon" word. If it is there then "rmmod psmouse" which is what my touchpad appears as.

If it is not there, then test and reactivate the touchpad.

Code: Select all

#!/bin/sh
# Script to look for USB mouse and, if present, disable touchpad
# Can also be run to re-enable touchpad if usb mouse removed

if lsusb | grep "Darfon"  ; then
    rmmod psmouse
else
    modprobe psmouse
fi
For this to work, I made it executable, owned by root (chown) then followed Boo's instructions to get it to run automatically.

Result: One Happy Camper!

Hope that helps....
antiquexray
Level 5
Level 5
Posts: 604
Joined: Sat Nov 18, 2006 6:04 pm
Location: Albert Lea Minnesota USA

Post by antiquexray »

uggbootcity wrote:...used lsusb from terminal to list connected usb devices...created a text file called touchpadoff.sh...Pipe the output of "lsusb" into the "grep"...test for the "Darfon" word...then "rmmod psmouse"...reactivate the touchpad.

Code: Select all

#!/bin/sh
# Script to look for USB mouse and, if present, disable touchpad
# Can also be run to re-enable touchpad if usb mouse removed

if lsusb | grep "Darfon"  ; then
    rmmod psmouse
else
    modprobe psmouse
fi
...made it executable, owned by root (chown)...followed Boo's instructions to get it to run automatically.
Righhhht
User avatar
uggbootcity
Level 1
Level 1
Posts: 12
Joined: Fri Jun 29, 2007 8:37 pm
Location: Gold Coast, Australia

Post by uggbootcity »

Plug in your usb mouse, and in terminal enter the command:

Code: Select all

lsusb
What is the resulting output? Can you paste it in a reply?
antiquexray
Level 5
Level 5
Posts: 604
Joined: Sat Nov 18, 2006 6:04 pm
Location: Albert Lea Minnesota USA

Post by antiquexray »

uggbootcity wrote:Plug in your usb mouse, and in terminal enter the command:

Code: Select all

lsusb
What is the resulting output? Can you paste it in a reply?
OK

Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 002: ID 046d:c50e Logitech, Inc. MX-1000 Cordless Mouse Receiver
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
User avatar
uggbootcity
Level 1
Level 1
Posts: 12
Joined: Fri Jun 29, 2007 8:37 pm
Location: Gold Coast, Australia

Post by uggbootcity »

Being such a noob myself, I feel a little out of my depth explaining this, so apologies for any syntax inaccuracies, or if this is not the best way of doing this. I just know it worked for me.
antiquexray wrote:
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 002: ID 046d:c50e Logitech, Inc. MX-1000 Cordless Mouse Receiver
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
What this tells me is that your MX-1000 mouse is what is being seen. I need some unique text to search for, so I am using "MX-1000"

I would change my script to take out "Darfon" (my mouse) and look for "MX-1000" instead.

Paste the following in your text editor:

Code: Select all

#!/bin/sh
# Script to look for USB mouse and, if present, disable touchpad
# Can also be run to re-enable touchpad if usb mouse removed

if lsusb | grep "MX-1000"  ; then
    rmmod psmouse
else
    modprobe psmouse
fi
In my HOME directory, I have a subdirectory called Utilities. I saved the new file there and called it "touchpadoff.sh"

I need to make it executable, so I can run it like a program, so

Code: Select all

chmod 755 touchpadoff.sh
Now I can test it from terminal

Code: Select all

sudo bash touchpadoff.sh
Let me know if that works so far!
antiquexray
Level 5
Level 5
Posts: 604
Joined: Sat Nov 18, 2006 6:04 pm
Location: Albert Lea Minnesota USA

Post by antiquexray »

uggbootcity wrote:I feel a little out of my depth explaining this...I just know it worked for me.

Let me know if that works so far!
COOL! That worked and my touchpad mouse no longer does! Now what?--this is so cool--thanks.

PS. How do you reactivate the usb mouse?
User avatar
Boo
Level 7
Level 7
Posts: 1633
Joined: Mon Mar 26, 2007 7:48 am

Post by Boo »

plug in usb mouse.

well you can reboot... overkill :lol:

or just run the script again

sudo touchpadoff.sh

:D
Image
Now where was i going? Oh yes, crazy!
antiquexray
Level 5
Level 5
Posts: 604
Joined: Sat Nov 18, 2006 6:04 pm
Location: Albert Lea Minnesota USA

Post by antiquexray »

Boo wrote:the script can be run from /etc/rc.local at boot.

in the rc.local file put the full path to your script.
it will be run as root.

:D
I obviously am missing something in my understanding and or syntax. Here is the contents of my rc.local file:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/phil/Utilities/touchpadoff.sh

exit 0

but it doesn't disable automatically.

***EDIT***

OK, I figured it out. The correct syntax is:

sudo bash /home/phil/Utilities/touchpadoff.sh

...and yes it works great.
User avatar
uggbootcity
Level 1
Level 1
Posts: 12
Joined: Fri Jun 29, 2007 8:37 pm
Location: Gold Coast, Australia

Post by uggbootcity »

antiquexray wrote: OK, I figured it out. The correct syntax is:

sudo bash /home/phil/Utilities/touchpadoff.sh

...and yes it works great.
You should not need to have sudo in the command, because the script gets run as root.

I am glad you sorted it out. I was so frustrated by the touchpad, and lost so much time before I was able to fix it...
antiquexray
Level 5
Level 5
Posts: 604
Joined: Sat Nov 18, 2006 6:04 pm
Location: Albert Lea Minnesota USA

Post by antiquexray »

...correct syntax is sudo bash /home/phil/Utilities/touchpadoff.sh...

You should not need to have sudo in the command...
You're right! It does work. I too will no long have the inadvertant deletion of text. Thanks again.
User avatar
Boo
Level 7
Level 7
Posts: 1633
Joined: Mon Mar 26, 2007 7:48 am

Re: Touchpad disable script help

Post by Boo »

try:
sudo modprobe psmouse

i would write the script this way:

#!/bin/sh
if [ $( lsusb | grep MX310 ) ]
then
modprobe -r psmouse
else
modprobe psmouse
fi

Boo
Image
Now where was i going? Oh yes, crazy!
Locked

Return to “Other topics”