Thursday, January 26, 2012

Disabling the default usb autosuspend in userspace on Debian Linux for keyboard and mouse

I've got a Microsoft USB 3000 mouse and a portable mini Holtek Semiconductor keyboard for my laptop. When the laptop is on battery power the default timeout for these devices is just 2 seconds, which is really mode. I mean really dumb. I mean just annoying. There's a few informational articles online that led me to this fix most notably : http://forums.whirlpool.net.au/archive/350749 

The only real problem was that the devices in /sys/bus/usb/devices don't match up to the device ID's in lsusb. But not to be deterred, by plugging and unplugging the devices in question, and comparing the output of  ls -latr /sys/bus/usb/devices  I was able to determine their correct device path in the filesystem.

So from there the fix was easy. Just find the path of the Microsoft USB 3000 mouse in the linux usb device directory, in this case, ./1-1.3 and
# cd /sys/bus/usb/devices/1-1.3/power; cat 60 > autosuspend; cat 60000 > autosuspend_delay_ms



Now my mouse doesn't suspend for a minute. Much more usable. I just wish this logspot had markdown or code tags.

Tuesday, January 24, 2012

TL;DR Here's the code:
search="font"; for x in $({ apt-cache search $search | grep $search | cut -f1 -d' ' ; dpkg -l | grep $search | awk '{print $2}' ; } | sort | uniq -u ); do apt-cache show $x  | sed -n '/Package/p;/^Description-en:/,/^Description-md5:/p'; done


Unfortunately not every package info given by apt-cache show has the same layout, so sometimes Package: is printed twice and sometimes all the package's info is printed out. We'll have to work on that.

So let's say you wanted to do the following in Debian/Ubuntu:
compare the packages you have installed pertaining to term "A" (dpkg -l | grep $A) with a list of all available packages pertaining to term "A" (apt-cache search $A | grep $A) and then print a list of those which are NOT currently installed but which pertain to term A.
The easy way to say that is "print me all packages i don't have installed containing $A in their name or short description". I believe this would be accomplished in yum with ``yum show uninstalled | grep $A'' but not totally sure.

Furthermore, I want to take that list and print the descriptions of those packages with their Package Name, so I can browse what I want to install.

Yes yes you may say I could use a software center or synaptic but whatever. This is way easier and I figured out two important things about both sed and bash.