SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-11-09 18:33:50

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

How To: disable (Synaptics) touchpad when an USB mouse is connected

i never use my touchpad except for when i don't have my USB mouse connected. so it would make sense to have it disabled when i do.
i've read on the Arch-wiki that you can do this through udev, but i'm not quite confident enough to try that out yet, and then i stumbled across this simple solution, which i really like, because it is so simple. in fact, it is a bit of a hack, but it works.

this is for synaptics touchpads only, as the synclient is the synaptics touchpad driver. however, the concept stays the same for any other touchpad i guess.

make a bash-script somewhere (some place where you have your bash scripts). i called it 'touchoff.bash'.

gedit touchoff.bash

Gedit opens to an empty file. copy-paste in this code:

#!/bin/bash
# thank you: http://www.linuxquestions.org/questions/debian-26/shmconfig-in-debian-645503/#post3838794
# script to turn off touchpad if mouse present at login
# synclient is the synaptic utility to manage the touchpad
# grep the "lsusb" output and do a wordcount on number of lines with "Logitech" which should = 1 if a Logitech mouse is present
#
# Obviously the "Logitech" should be replaced with your brand of mouse, and perhaps be more exact in case you have other USB devices that have similar names
/usr/bin/synclient touchpadoff=`lsusb | grep Logitech | wc -l`

save it.
now type:

chmod +x touchoff.bash

this makes it executable.

now, if you want to try how this works in the terminal (for better understanding, and to test if it actually works), type this:

synclient touchpadoff=1

this should disable the touchpad (try it!) to enable it again, type:

synclient touchpadoff=0

so now you have your own script for switching the touchpad on and off when a USB mouse is present. however, this is not nearly good enough. we want this stuff to happen automatically on start-up! so, let's add it to the Openbox autostart.sh file.
right-click somewhere to bring up the Openbox menu. go: Settings > Openbox Config > Edit autostart.sh
in the file, move somewhere to the bottom, so all the other stuff is loaded already before executing this command. now add the link to your script. for me, this is:

/usr/local/bin/scripts/touchoff.bash &

for you it might be a different directory, so mind that stuff. also, do not forget the &. if you want to know why, read the autostart.sh documentation, google it.

try it out! logout, log back in, and see if it works!

Offline

Be excellent to each other!

#2 2011-11-09 19:16:06

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,163
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Great How To rhowaldt

Well written and precise..


VSIDO | Words That Build Or Destroy

We do not run from challenges, they become new innovations within VSIDO!

Offline

#3 2011-11-09 19:38:16

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

^ i hate... hey, i hate a lot of things! anyway, i didn't really like it when i was very very new to linux that there were people explaining things halfway. so stuff like 'put that in your config file'... and me: 'where the hell is the file?'... have to do a separate google to find that out, while he could've been more specific. explain stuff, we are all newbies damnit!

so, you know that one song by Michael Jackson, that goes: "if you wanna make the world a better place, take a look at yourself and make that, CHAAAAAAAANGE!"... so that's why!

Last edited by rhowaldt (2011-11-09 19:40:22)

Offline

#4 2011-11-09 19:40:39

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,163
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

lol... That is the ONLY song by MJ I ever liked and own

I use the same philosophy in all of my How To's as well


VSIDO | Words That Build Or Destroy

We do not run from challenges, they become new innovations within VSIDO!

Offline

#5 2011-11-10 01:24:50

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,631
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Very nice, very nice, thanks Ro!
I additionally have 'ton.sh' and 'toff.sh' scripts which are simply synclient touchpadoff=0/1 called by keyboard shortcuts. There is also syndaemon to disable touchpad when typing...

100 Euro Question: How to disable mouse when touchpad is connected? big_smile (kidding)

Offline

#6 2011-11-11 03:16:07

bennisixx
#! CrunchBanger
From: the woods arkansas
Registered: 2011-11-10
Posts: 127
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

thank you for this.

Offline

#7 2011-11-11 15:26:16

brunomalone
Member
Registered: 2009-10-20
Posts: 22

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Thank you rhowaldt!

Offline

#8 2012-02-04 12:39:13

len
Member
From: Another World
Registered: 2012-01-24
Posts: 21
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

it's really great works..


┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳
┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻
┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳┻┳
Future is like a WALL.

Offline

#9 2012-05-15 12:53:43

oylenshpeegul
Member
From: Maryland, USA
Registered: 2012-01-01
Posts: 37
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Nice write up!

On waldorf, I had to install usbutils first, to get lsusb

sudo apt-get install usbutils

Offline

#10 2012-05-25 17:34:24

Resident Bot
#! Die Hard
From: The Netherlands
Registered: 2012-02-17
Posts: 604

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

i see a lot of stuff around on turning off your touch pad but no-one says why?  I dont use my touch pad but what advantage is there in turning it off - is it using a lot of resources or something?


Troll = not a fanatic
slave of #!  and arch

Offline

#11 2012-05-25 17:37:11

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Techniques to Disable Touchpad – Why would you want to?

Want to know how to Disable the Touchpad on your laptop? There are many reasons to want to turn off or disable touchpads. I know it frustrates me greatly when the bottom of my palms brush the touchpad. The character I was typing suddenly quits appearing, and the random mouse and keyboard effects that happen next cause me no end of grief. Occasionally, I will run across a touchpad that is malfunctioning and is causing random effects without being touched, and there is good reason to want to disable it for this as well.

(from http://disabletouchpad.net/; the "techniques" are for Windows)

Last edited by pidsley (2012-05-25 17:40:10)

Offline

#12 2012-05-26 09:22:23

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

^ exactly that. i touch my touchpad with the bottom of my hands when i type, my mouse moves around, it is annoying. plus, i never use it. so anything i never use AND is annoying at the same thing, i turn off big_smile

Offline

#13 2013-05-01 01:13:29

astoria
Member
Registered: 2013-05-01
Posts: 12

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Yeah, this doesn't work for me. I'm 100% I did everything correct. I went over everything a lot of times. It doesn't work.

The scrip works. If I click it. So clearly, lsusb works, the script works, the touchpad gets disabled if I have my mouse in and it doesn't if I  don't.

The problem is that it's not automatic. I tried relog, restart, nada.
If I un-plug and plug my mouse again the touchpad stays on.

If I start #! with my mouse plugged in the touchpad stays on.

Whatever I do, the touchpad only turns off if two conditions are met
1) I click the script
2) The mouse is plugged in

Both in the same time.

The autostart is set fine. I've put the touchoff.bash in /home/astoria/documents/touchoff.bash &

Offline

#14 2013-05-01 07:21:50

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,958

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

^ It's not meant to be automatic, it's meant to run once on log in.

If you want things to be automatic, e.g. when you (un)plug your mice, you need to go with udev rules: https://wiki.archlinux.org/index.php/To … _detection


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#15 2013-05-03 18:50:00

th3pr0ph3t
Member
Registered: 2011-03-02
Posts: 28

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

In my case, the command

synclient touchpadoff=1

worked immediately and was simple enough for me.

And thanks, this is the answer I was expecting.

Offline

#16 2013-06-30 12:21:27

Hachiman
#! Member
From: Indianapolis, IN
Registered: 2013-01-18
Posts: 81

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

th3pr0ph3t wrote:

In my case, the command

synclient touchpadoff=1

worked immediately and was simple enough for me.

And thanks, this is the answer I was expecting.

This also worked for me. My question is: Since I don't need the script, how do I make this the default loaded on startup?

regards
Hachiman

Offline

#17 2013-06-30 12:48:09

GekkoP
#! Junkie
From: Vicenza (Italy)
Registered: 2013-06-17
Posts: 297
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Wow, really helpful. Thank you.

Offline

#18 2013-08-13 00:46:13

Sisyphus
New Member
From: Huntsville, Al
Registered: 2012-03-20
Posts: 2
Website

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

Much obliged


In the depth of winter I finally learned that there was in me an invincible summer.
~Albert Camus

Offline

#19 2013-08-13 02:47:26

bleach
#! Member
Registered: 2013-08-09
Posts: 98

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

on startup include it in /home/one/.config/openbox/autostart file. add a line
synclient touchpadoff=1

if you need it back synclient touchpadoff=0 in console

another thing to do without script is to make shortcut keys


obstacles are only in your mind. how you deal with them is what "matters".

Offline

#20 2013-08-13 08:23:36

sano
#! CrunchBanger
Registered: 2012-03-07
Posts: 114

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

I achieve the same by having this in my .xinitrc:

if [ `ls -d /sys/class/input/mouse* | wc -w` -gt 1 ];then
synclient TouchpadOff=1
fi

To switch the touchpad on when unplugging the mouse, and off again when plugging it in, I have this:

 /etc/udev/rules.d/62-touchpad.rules

ACTION=="add", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceSubClass}=="01", ATTRS{bInterfaceProtocol}=="02", ENV{REMOVE_CMD}="/usr/local/bin/touchpadtoggle 0", RUN+="/usr/local/bin/touchpadtoggle 1"
 /usr/local/bin/touchpadtoggle

#!/bin/bash
export XAUTHORITY="/home/<username>/.Xauthority"
# xfile=$(find /var/run/gdm/ -name *<username>* -print -quit)
# export XAUTHORITY="$xfile/database"
export DISPLAY=":0.0"
/usr/bin/synclient touchpadoff=$1

You might have to find out how to handle authorisation if you don't use either slim or startx to start your WM/DE. The two lines I commented out are needed for GDM. The attributes in the udev rule should work with every USB mouse.

Offline

#21 2013-08-13 09:07:07

bleach
#! Member
Registered: 2013-08-09
Posts: 98

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

is there a command to toggle it?

for instance is there a way for a if 1=true then off and vice versa for a script?


obstacles are only in your mind. how you deal with them is what "matters".

Offline

#22 2013-08-13 09:51:33

sano
#! CrunchBanger
Registered: 2012-03-07
Posts: 114

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

bleach wrote:

is there a command to toggle it?

for instance is there a way for a if 1=true then off and vice versa for a script?

I don't really get your question -  I am not even sure if you are talking to me...

Anyway:

Both the snippet for xinitrc and the udev rule will toggle the touchpad according to certain conditions.

if [ `ls -d /sys/class/input/mouse* | wc -w` -gt 1 ];then... checks if there is more than one mouse connected and switches off the touchpad if true, and does nothing if false.

The udev-rule checks if a mouse is being (dis)connected and calls the touchpadtoggle script with the according parameter (0 when disconnecting it, 1 when connecting).

If you want to toggle manually, just use synclient TouchpadOff=X.

Offline

#23 2013-08-13 09:59:05

bleach
#! Member
Registered: 2013-08-09
Posts: 98

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

I was woundering if there was a single script that could be used for two functions.
touchpadoff=1 then touchpadoff=0 and vice versa. my reasoning is that it would be nice to get the touchpad on off button working.

edit: the more i think about it this may be a unintentional hijack let me know.

Last edited by bleach (2013-08-13 10:02:21)


obstacles are only in your mind. how you deal with them is what "matters".

Offline

#24 2013-08-13 10:10:42

VDP76
#! Bean Roaster
Registered: 2012-04-12
Posts: 832

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

^ you're looking for this script...


#!#!#! Forum etiquette #!#!#!
Are you a new member!? Have you introduced yourself?!
CLI basics | LVM | smxi | chrooting | multiarch

Offline

Be excellent to each other!

#25 2013-08-13 10:20:59

bleach
#! Member
Registered: 2013-08-09
Posts: 98

Re: How To: disable (Synaptics) touchpad when an USB mouse is connected

thank you that is what I was looking for.


obstacles are only in your mind. how you deal with them is what "matters".

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo