Stupid Linux Tricks

Stupid Linux Tricks

Monday, Nov 8, 2021 by Leon

It’s been a while since I’ve posted. Nothing earth shattering. Just been keeping busy with personal/family stuff and have picked up a few gigs on UpWork. From an IT standpoint I decided to try and make my work environment a little more efficient. Part of this was spurred on by spending an hour or two tracking down something that turned out to be the result of a keyboard-bounced character that I couldn’t spot easily. After that I decided to get a better keyboard, and set up a bluetooth mouse that I can take with me on the road.

While the keyboard is on order, and should be able to just be plugged in, the bluetooth mouse is something I’ve toyed with over the years but haven’t really had much success with.

As a little background, my laptop (a Lenovo X240) spends 95% of it’s time in a docking station next to my desk (and usually under a cat, but that’s another story). When I do take it on the road I find it annoying that brushing the trackpad or touchpoint devices have some undesired effects - especially since I’m using the Awesome Windows Manger. My windows and screens wind up flying around in the most undesireable ways. The local Officemax had a clearance on Logitech bluetooth mice so I picked one up and much to my surprise, the Linux support for it is much better than it was last time I tried it. The mouse automatically connects each time I reboot the computer.

Now when I’m on the road I can take the mouse with me, and if it’s turned on the following script that is run at boot time will automatically disable the trackpad and pogo stick on the laptop:

 1#!/usr/bin/tclsh
 2
 3set btMouse "Bluetooth Mouse M336"
 4set targetList [list "TPPS/2 IBM TrackPoin" "Synaptics TM2749-001"]
 5set disableList [list]
 6set gotBTMouse 0
 7
 8set inputpipe [open "| xinput list"]
 9while { [gets $inputpipe thisDevice] >= 0 } {
10	 set deviceName [string range $thisDevice 6 25]
11	 puts $deviceName
12	 if { $deviceName == $btMouse } {
13		 set gotBTMouse 1
14	 } elseif { [lsearch -exact $targetList $deviceName] != -1  } {
15		 puts $deviceName
16		 set thisId [string range $thisDevice \
17			   [expr [string first "id=" $thisDevice] + 3] \
18			   [expr [string first "id=" $thisDevice] + 4]]
19		 lappend disableList $thisId
20	 }
21}
22close $inputpipe
23
24if { $gotBTMouse } {
25	foreach thisDevice $disableList  {
26		exec xinput disable $thisDevice
27	}
28}