Sunday, 15 April 2012

Fix mouse sensitivity (Razer Diamondback 3g)

After plugging in a Razer Diamondback 3g in Ubuntu 11.10 I found that the sensitivity was spectacularly high, and I was unable to edit it using gnome settings.

The fix is to manually edit xorg.conf to set a constant deceleration for the device in question.

sudo gedit /etc/X11/xorg.conf
Whether or not the file exists, simply append the following:

Section "InputClass"
     Identifier "mouse speed adjustment"
MatchIsPointer "on"
MatchProduct "Diamondback 3G"
Option "ConstantDeceleration" "2"

Where MatchProduct will look for a device name containing what is specified. This can be found by running:
cat /proc/bus/input/devices
and scanning the resulting output for the name of the device in question.

The higher the number associated with ConstantDeceleration, the less sensitive the mouse will be.

Hope this helps.

Monday, 9 April 2012

Automatically kill process using too much memory (Skype for Linux)

Recently i've found Skype 2.2 beta for Linux has been infrequently succumbing to massive memory leaks. Most of the time it will perform fine, however it will very occasionally manage to hose the entire system with horrific swapping and make everything unresponsive.

With no updates seeming to be forthcoming from Skype these days, a workaround seemed necessary. The solution being in the form of a clever perl script called Timeout being used to launch Skype.

Download the tarball (or zip) from the github repository and extract it somewhere appropriate:

tar -xvf nameofarchive
Navigate to the directory you've just extracted and make the script executable
chmod 777 timeout
Then you can use it to launch skype thusly
 ./timeout -m 1000000 skype 
Where -m tells it to watch the memory consumption, and is followed by the memory limit you wish to set in kilobytes. Here I set it to kill skype if it uses more than one gigabyte of memory.

To launch Skype like this all the time, use a program like Alacarte (Main Menu Editor) to change the command the Skype menu entry launches with to the path of the script. It should look something like:
/home/username/scripts/timeoutdir/timeout -m 1000000 skype
After running like this for a while I found that the script was using more cpu time than seemed reasonable, as it was running ten times a second, so I modified it to run once every ten seconds instead, which removed it entirely from concern, both cpu and power consumption wise.

To do this you'll want to open the timout script itself in your favourite editor
gedit timeout
And find the line that says 'my $frequency = 10;'

Change this to look like 'my $frequency = 0.1;'

Save and exit.

Hopefully this makes life easier for anyone afflicted similarly. You can of course use this to monitor and limit any process with regards to cpu or memory usage by utilising the timeout script to launch it.