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!

Saturday, 19 November 2011

Create persistent Bash aliases


Having recently updated to Xubuntu I found that the command "l" no longer showed a colourised 'ls' output, which was rather irritating. The solution is, of course, to re-create the bash alias so that the command 'l' executes what I expect it to. I'm unsure whether or not I managed to remove this functionality myself at some point, or whether it's simply not a default alias in Xubuntu.

In any case, I didn't have a .bashrc file in my home directory, so the first thing I did was to copy the default one to it:

cp /etc/skel/.bashrc ~/
It turns out this is enough to get the 'l' command back, as it already exists in that bashrc. Having had a look through this default .bashrc though, I couldn't resist the temptation to add another alias for convenience!

Simply append the following to the end of your ~/.bashrc to have the terminal update and upgrade when you type 'update'
alias update='sudo apt-get update && sudo apt-get dist-upgrade'
It's tempting to go nuts and start adding aliases left right and centre for mundane tasks, this is something that should probably be resisted for anything that isn't both genuinely useful, and frequently executed however.

Friday, 11 November 2011

Force Nvidia Powermizer to always set performance mode - Ubuntu 11.10 (Update)


This is an update from an older post, as that particular method no longer seems to work in the latest version of Ubuntu. This one, however, does.

Open xorg.conf with your favourite editor:

sudo nano /etc/X11/xorg.conf
Add the following line under the section "Device"
Option "RegistryDwords" "PerfLevelSrc=0x2222"
So that your device section looks something like this:
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
Option "NoLogo" "True"
Option "RegistryDwords" "PerfLevelSrc=0x2222"
EndSection
Save and reboot, hopefully your performance level is now always at maximum.

Monday, 24 October 2011

Moving windows laggy in Compiz


A most irritating bug whereby windows will jerk and lag when attempting to move them, either after compiz has been running for a bit, or just after a viewport/workspace change.

The problem appears to be something to do with mouse polling in compiz, and the fix is to limit the rate at which your mouse can be polled.

Following the solution posted here:

sudo gedit /etc/modules
Add the following to the end of the file:
-r usbhid
usbhid mousepoll=10
Save and reboot. Hopefully moving windows is now back to being smooth!

Friday, 21 October 2011

Manually change GTK3 theme in Xubuntu, Xfce 4.8


Due to a rather intense dislike of both Unity and Gnome-Shell in their current iterations, I've recently switched to using Xubuntu. One quibble i've had is that changing the theme in xfce4-settings-manager often causes the theme used with gtk3 applications to revert to the ugly default, presumably as many themes do not have gtk3 counterparts to display.

The only solution i've been able to find with regards to manually changing the gtk3 theme is to hunt down the theme folder in /user/share/themes and copy the gtk-3.0 folder from that theme into ~/.config.

So if you've changed the theme and just want the default greybird gtk-3.0 theme back for your gtk3 apps, while keeping a different theme for your gtk2 applications you might run something along the lines of:

cp -r /usr/share/themes/greybird/gtk-3.0 ~/.config

For applications run as root to adapt to this theme too you'll need to copy to /root/.config also.
sudo cp -r /usr/share/themes/greybird/gtk-3.0 /root/.config

Hope that helps someone, as it was beginning to annoy me rather a lot. If anyone has a cleaner way to do this please let me know.

Thursday, 26 May 2011

Ubuntu - Skype won't start, crashes with aborted.


Completely out of the blue a previously working install of Skype started crashing out every time it was started. The window would flash up briefly, and then dissapear, leaving an "aborted" message in the terminal. I'm unsure as to what caused this, as I hadn't recently applied any updates, however I eventually found a fix.

For 64 bit the problem appears to be to do some combination of ia32-libs and the Skype temporary directory. So (skip to the second command if you're using 32 bit):

sudo apt-get install --reinstall ia32-libs
and remove the skype temporary directory (This will remove stored passwords and conversations):
rm -rf ~/.Skype
Start Skype again and hopefully it'll work! While searching for information on this problem I saw a fair few different fixes, with differing success rates, so while this may or may not work for you, it's worth a try.

Otherwise, this thread on launchpad may help.

Edit: The problem seems to be fairly widespread, and across distributions - So I suspect Skype have managed to do something that has broken current installations of their program on Linux.

Edit2: A less intrusive and more specific alternative of the second command appears to go along the lines of (thanks to whoever commented this):
 rm ~/.Skype/shared.xml
This will preserve things like your chat history. As this is the file causing the problem.

Monday, 11 April 2011

Install Steam version of Darwinia natively in Ubuntu 64 bit


Idle hands end up fiddling with stuff when you have a Linux distro at your fingertips!

So having this game in my steam list led me to wonder if it was possible to install Darwinia on my Linux box without repurchasing the game. Happily, it turns out that it is, though it requires a little bit of fiddling to get running.