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"
EndSection

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.

Friday, 24 February 2012

Use Bumblebee/optirun to launch program from Codeblocks


The Intel integrated graphics driver is wonderfully stable, it's does not, however, play particularly well with certain opengl calls, and rendering apis.

The solution if you have an optimus laptop is to install bumblebee and run the program with the optirun command. This ensures that it is rendered with the Nvidia chip, and using the Nvidia proprietary blob. Making this happen by default when you launch a program from your IDE is therefore desirable.

Thankfully, for Codeblocks it's fairly simple; You just need to add "optirun" to the terminal launch option in Environment -> General.



This only works if you have your program set to launch as a console application, however, when working in the IDE this is usually the case. The program can be launched externally with optirun for release builds set as to compile as gui applications.

If anyone has a better solution that would ensure all application type settings automatically utilise optirun, i'd love to hear them!

Intel integrated graphics tearing in Gnome 3/Shell


I recently purchased a new laptop that has an Intel integrated graphics chip as part of its graphics arsenal, and found it was tearing slightly in Gnome 3/Cinnamon.

The solution, happily turns out to be very simple.

sudo nano /etc/environment
Append the following the the end of the file
CLUTTER_PAINT=disable-clipped-redraws:disable-culling
ctrl+x to quit and save

Log out or reboot. Done!