Linux

Rotating wallpaper

Topics

I've been working a while on a Windows 7 machine, and one of the nice desktop blings there is the rotating wallpaper item. There are quite some sets available, and you can download many more (eg like the famous Bing backgrounds). Linux has this functionality already since some time, but the sets of available wallpapers there are quite limited.

I've played around with Drapes, but the rotation time is quite small (I want maximum one wallpaper rotation per day). So why not write a script which downloads automatically some wallpaper from sites like APOD, Bing or National Geographic ?

Here are some scripts I found on the internet which do this for you. Place them in your crontab with a frequency of your liking.

Bing

#!/bin/bash
# modify this, if you want to save to other place
#  - $HOME: your home dir
#  - %F: full date (%Y-%m-%d)
#  - other date format: man date :P
OUTPUT=`date "+$HOME/Pictures/bing_bg.%F.jpg"`

# get the bing.com page, and separate the background image (DONT touch this)
IMG=`wget -q http://www.bing.com -O- | sed -r "s/[\]//g;s/.*g_img=\{url:'([^']+)'.*/\1/gp;d"`

# get the background image to the output (DONT touch this)
wget -q "http://www.bing.com$IMG" -O "$OUTPUT"
# error handle
if [ $? -gt 0 ]; then
        echo "there is a problem with downloading.."
        exit 1
fi
# Setting background-image.
# NB: Use an absolute URL
gconftool-2 -t string -s /desktop/gnome/background/picture_filename "~/Pictures/bing_bg.%F.jpg"
gconftool-2 -t string -s /desktop/gnome/background/picture_options "zoom"

National Geographic

#!/bin/sh
#Based on code of APOD, you can really find everywhere on the web.

#Downloading html of the Picture-Of-The-Day
wget -N http://photography.nationalgeographic.com/photography/photo-of-the-day/ -O /tmp/ngpod.html
#Getting the URL of the image
img_location=`egrep -o "http://images.nationalgeographic.com/[^]*\.jpg" /tmp/ngpod.html|head -n 2|tail -n 1`

rm /tmp/ngpod.html

#Download image
TODAY=$(date +'%Y%m%d')
wget $img_location -O ~/Pictures/$TODAY.jpg

# Setting background-image.
# NB: Use an absolute URL
gconftool-2 -t string -s /desktop/gnome/background/picture_filename "~/Pictures/$TODAY.jpg"
gconftool-2 -t string -s /desktop/gnome/background/picture_options "zoom"

Running the native Nvidia drivers

Topics

Since the upgrade to Karmic on my desktop, graphic performance has gone down considerably. I solved this in the past by downgrading Nvidia, but since Lucid, this has become impossible. It's not that I cannot live without the desktop bling, but suspend-resume is impossible without running the Nvidia drivers. The problem manifest itself by very high CPU bursts by kernel processes (kondemand, ksoftirqd), which makes the desktop unworkably slow.

I tried everything, from disabling PAT, KMS modesetting, switching framebuffers, all without success. I even tried to enable Lenny's Nvidia drivers, but that pulled in a 2.6.26 kernel, which I cannot use, because my filesystems are ext4.

I eventually turned in despair to the Nvidia website, looking for older drivers. The 173 release was still available in the archive download section, which came as a ncurses-based installer. These Nvidia based drivers are famous for messing up a Linux system, so I was rather reluctant to use those. I still decided to give them a go, which rather went surprisingly really well.

Finally a performant system again !

OpenVE

Topics

Proxmox OpenVE looks the closest to a VMCenter/VMSphere alternative based purely on Linux (Debian to be more precise). You can add pure virtualized environments a la VMware guests, or run container based Linux(-only) guests. It comes with a cluster option with live migration possibilities.

Two disadvantages on first sight :

  1. It's 64bit only
  2. It comes only in the form of an appliance-based installation (which will wipe your /dev/sda)

Apart from that, very promising.

Migrate to ext4

Topics

Since the Ubuntu Lucid upgrade, suspend/resume is not working any more on my desktop, which means I must powercycle every day. This leads to a higher fsck rate on my mounted filesystems, and as those are increasing in size over time, this takes a long time to boot. This is why I decided to migrate everything to ext4, thereby offering me faster fsck times, and an overall better performance.

The procedure to migrate ext3 volumes to ext4 is quite straightforward :

For non-root filesystems :

First, unmount the partition.

umount /dev/sda5

Next, run a filesystem check on it to make sure it is in sane condition. We are still on ext3.

fsck.ext3 -pf /dev/sda5

Enable new features of ext4 on the filesystem.

tune2fs -O extents,uninit_bg,dir_index /dev/sda5

Option "extents" enables the filesystem to use extents instead of bitmap mapping for files, "uninit_bg" reduces file system check times by only checking used portions of the disk, and "dir_index" allows storing the contents of large directories in a htree for faster access. Option "dir_index" is also supported by ext3, so you may already be using it, but it makes no harm to specify it here.

Run a filesystem check. It will find errors. It is normal. Let it fix them.

fsck.ext4 -yfD /dev/sda5

The "-D" parameter will actually enable the "dir_index" option by rebuilding directory index. It can be rebuilt (optimized) at any later time by running the check with the parameter.

Now edit your /etc/fstab file to say "ext4" instead of "ext3" for /home. Other options may differ for your system.

/dev/sda5 /home ext4 defaults 0 2

Try to mount your new ext4 filesystem.

mount /home

If it succeeds, congratulations.

It may seem that the migration from ext3 to ext4 is now complete, and it is almost true. Except that any old files created before the conversion will continue using the bitmap mapping of ext3 instead of extents of ext4. Files will eventually migrate to the new format as they are updated during normal system operation, because on next write they will be saved using extents. Unfortunately many frequently used files (like application binaries) are often read and rarely written to. The outcome is that the files will remain using the old format for a long time, and you will not be able to experience full potential of ext4. Modifying attributes with chattr can be done on multiple files. Although digging trough the entire directory system is not really feasible, so you can use some of the shell magic to accomplish the task.

find /home -xdev -type f -print0 | xargs -0 chattr +e

For root filesystems :


You will need to use a Linux liveCD, or the installation CD that came with your distribution. You might want to check if the kernel on that installation medium has ext4 capabilities. Simply follow the above procedure, but don't forget to change /etc/fstab first, so your root partition is marked as ext4.

Linux support for the Lexmark X1250 printer/scanner

Topics

Sweet ! I was about to install drivers in a Windows7 virtualbox for my el-cheapo Lexmark X1250 printer/scanner, when the Sane dialog popped up on my Linux desktop when I switched on the power. I decided to have a quick look if it was supported under Linux (without much hope, I must say), when I stumbled on this page with detailled instructions. I didn't had to copy the libsane shared lib, so eventually, the scanner was supported with the following instructions :

and voila ! Scanning time...