Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, July 12, 2011

Linux kernel 2.38 and Ubuntu Natty: The devourer of laptops

Some of you have undoubtedly installed a Linux distribution featuring the kernel 2.38 (or a latter version). This kernel comes with Ubuntu 11.4 Natty Narwhal but also in Fedora 15 and some rolling release distributions like Arch or LMDE.

While installing a new fancy distro carries the advantage of bringing you with the latest packages including the new fool-proof desktop environments that have been recently in the spotlight (unity and gnome 3) it will also bring you to one of the most annoying bugs that I have dealt with.

All the Linux kernel versions starting with 2.38 made changes to the Active-State Power Management (ASPM) that have resulted in a dramatic power consumption increase. This might be not so evident for a desktop computer but can easily trounce the charge duration of a laptop by a third, not to mention the fact that it turns it into a portable pan.

To fix this we need to enable the pcie_aspm=force option. The downside is that this might turn some systems unstable or even prevent them from booting. Use this at your own risk.

A simple way to see if this fix will work for your recently turned into pan laptop is to enable this option for a single boot. In Ubuntu you need to select your Ubuntu system and press e in the menu that allows you to choose an operating system just after turning on your computer. This allows you to edit the boot options for this session. Locate something looking like quiet splash and add pcie_aspm=force inmediately next to it, separated by a space. If your computer boots and remains stable you will notice that it will heat considerably less and that  battery life is extended.

Now, to make this change permanent we need to edit the bootloader. Open a terminal and enter:

gksu gedit /etc/default/grub

which will ask you for privileges escalation (the password of the administrator). Then, look for this line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

and change it to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pcie_aspm=force"

Make sure that this is indeed how the line looks like, we don't want to screw the bootup. After that we need to update the bootloader:

sudo update-grub

And that's it, you have rescued your laptop from becoming your next broiler. Just reboot and the change must be there permanently.

Friday, January 01, 2010

Create wallpaper slideshow in Ubuntu 9.10

First of all, happy new year! Nothing like the morning of a new year to be messing around with Linux and Python!

One of the new things in Ubuntu 9.10 is that you can now use a wallpaper slideshow for your desktop, which will cycle your desktop wallpaper at regular intervals from a selected pool of wallpapers. The default Ubuntu 9.10 comes with a space-themed wallpaper slideshow, but there is apparently no option to create your own ones. However, the configuration is stored in plaintext XML files, one in /usr/share/gnome-background-properties and the other in the corresponding directory where the images are stored, in /usr/share/backgrounds.

The following Python script will automatically create these two XML files so that you can set a wallpaper slideshow with the images of your preferences.

Slideshow Builder script
(Right-click and select "Save Link As..", or the equivalent in your browser).

Here's the instructions. You will need root access since the directory where you're doing the operations, /usr/share/, is owned by root. Simply use sudo (or sudo -i if you're lazy).

1) Create a directory in /usr/share/backgrounds with the name of your slideshow. For instance, if the desired name is 'space', the dir should be called '/usr/share/backgrounds/space/'.

2) Copy all the wallpaper images to that folder. The supported formats are jpg, png, gif and bmp.

3) Run the Python script in the images directory. This will automatically create two xml files: one in the (current) images directory, and another one in /usr/share/gnome-background-properties.

4) That's all! You can now select the slideshow in the Gnome wallpaper selection interface.

A sample usage of the script is shown in the following image:


And the slideshow now appears in the desktop Background selection screen:


Update: I've fixed the dead link to the script.

Wednesday, September 23, 2009

Fixing unrecognized File Type extensions in Ubuntu

I've had a little 'bug' in my Ubuntu for the past month that was annoying me a bit. I use TeXmacs for creating/editing small LaTeX documents. The problem is that Nautilus was incorrectly detecting the file type of .tm files, thinking they were plain text documents (see image below). The consequence is that TeXmacs files would be opened in gedit (or the default text editor) when opening them through the Nautilus file browser.



The first solution attempt was right-clicking a .tm file, going to "Properties -> Open With" and changing the default application to GNU TeXmacs. This was a disaster, since now *all* plain text files would be opened in GNU TeXmacs, since Nautilus genuinely believed a .tm to be the same as a .txt and thus changed the default application for all text files.

My second attempt at a solution (after googling a bit) was checking the MIME file type associations, which is the way Ubuntu associates an extension to a file type. The info is all in the file /etc/mime.types. However, to my disappointment, this file already contained a mime type for TeXmacs documents, indicated by the entry
"text/texmacs tm ts". So even though the mime type was correctly recognized, it seems Nautilus wasn't picking it up. This could be further deduced from the fact that running the command file on a .tm document in the terminal returned the correct mime type.

After more googling, I finally discovered that this is in fact a bug and found a fix for it:

http://savannah.gnu.org/bugs/?25938#discussion

Essentially, you manually create an xml file describing the TeXmacs mime type to /usr/share/mime/packages and then manually update the mime database of the system (setting an icon for the file type is optional, but may be useful).

NOTE:
the original poster of the above bug fix made a small typo: an extra semicolon (;) at the end of the line containing "mime-info xmlns=" Remove it before trying to update the mime database.

After this is done, logout / re-log (or simply kill / restart nautilus from the terminal) and the new file extension should now be recognized:



The nice thing about this is that it should conceivably work for any other file type that has a correct mime type in /etc/mime.types but is not being recognized by Nautilus.

Hope this was helpful ;).