So I love my new massive desktop replacement of a laptop. It’s fast, has plenty of RAM (for now at least), and plenty of Cores. But it suffers from some of the same old issues every other laptop with a touchpad causes me. When typing, it occasionally causes my cursor to end up in really strange places on my screen which results in messed up words or variable names. On my MacBook Pro and in Windows I could disable the touchpad as soon as a mouse was connected. I spent days trying to find the same settings on Linux and then ran across a few articles written by people who just wanted to turn off the trackpad for good. That sounds good until you forget your mouse at home. So I decided I needed to write my own script. In a mere 38 lines(without comments) I came up with a script that looked to see if my mouse was connected and if so disable the trackpad. If the mouse disappears or is removed the trackpad is re-enabled within 30 second. If you want to use this script you will want to do a few things first:
- remove your mouse
- run “xinput list” determine what the system thinks your trackpad is called
- plug-in the external mouse/pointer
- run “xinput list” again and determine what the system thinks it’s name is
My trackpad comes up as a ALPS GlidePoint. If yours is different, which it likely will be, then you need to replace ‘ALPS GlidePoint’ in line 5 with the name of your trackpad. If it is the same name then you don’t have to do anything with line 5.
My mouse comes up as ‘Logitech USB Receiver’ cause that sounds like a mouse right? Well it is really the name of the wireless receiver for my mouse. I shorted the name to just ‘USB Receiver’ in the hopes that any future wireless mice I may buy will use that part of the same name. (Yeah I know there is about a 0% chance of that happening but I can dream can’t I?) If yours is different, which like above it likely probably be, replace ‘USB Receiver’ in line 6 below. If it’s the same then you don’t have to do anything with line 6.
The complete script can be found at this link.
One thing I did above that you may want to try in your scripts was to use the logger command instead of echo. Logger uses the syslog subsystem and lets you write whatever you want to the default log for syslog. Where to write is of course configurable if you need it to go somewhere else. A word of warning though, logger will not move on if there is nothing to log. It freezes and waits for you. So like I did above, check to see if there is something in the variable before using it with logger. Logger is available on most *nix versions. If it’s missing you can normally find it as part of a syslog related package.