imap sent or sent items?

Imap rocks, especially since Thunderbird 3.0 and its smart folders allow all email accounts to look like local folders. Emails can be left on the server, where proper backups can be configured, and emails can be accessed from any number of devices and clients, including webmail. Having to nip home to check email is just so 1990s.

It’s not all jolly jolly however. Outlook hasn’t yet followed Thunderbird’s lead – each additional imap account means another sheaf of folders to watch for new mail. But the most irritating aspect of everywhere email with multiple clients is the lack of standardisation of folder names. Oh yes, there’s always an INBOX. But schizophrenia sets in around the Deleted Items folder, which likes to be Trash now and then. And that email I just dispatched – was it Sent? Or a Sent Item? I’m sure we all agree that Spam is also Junk, but at the risk of being accused of folderism, c’mon, won’t one folder do?

Having the ability to create folders that are instantly available to all my clients is great, truly. But the default four – Inbox, Sent, Trash and Junk – please let us all agree on these. I for one don’t want seven folders for each account where four will do.

Siemens SE 587 Dynamic DNS Update script

Quick script I knocked up to update dynamic dns record at freedns.afraid.org, querying the router for its IP address. Uses expect to login via telnet to the router and curl to GET the http update url.

#!/bin/bash
# Siemens SE 587 freedns update script
# Jonathan Cutting mcmlxxii.co.uk
# 20/9/2009

# Config
router_login="your_login_name"
router_password="your_login_password"
router_address="192.168.1.1"
afraid_url="your_dynamic_dns_url"
afraid_update_url="http://freedns.afraid.org/dynamic/update.php?YOUR_UPDATE_CODE"
# End config

dns_record=$(dig +short $afraid_url)
ip_address=$(expect -c "
    set timeout 15
    spawn telnet $router_address
    expect gin:
    send \"$router_login\r\"
    expect word:
    send \"$router_password\r\"
    expect >
    send \"ip show interface ipwan\r\"
    expect >
    exit
" | grep Ipaddr | awk '{print $3}' | sed -e 's/^M//')

if [ $ip_address != $dns_record ]
then
    date
    curl $afraid_update_url
fi

AR5008 and Network Manager.

In both Ubuntu Jaunty and now Karmic, I have been experiencing pretty dreadful wireless performance using a combination of the Atheros AR5008 chipset and the default GNOME connection management tool Network Manager. I have read elsewhere that Network Manager scans at regular intervals for available networks in the vicinity, which appears to have the effect of disassociating the AR5008 from the current access point, and this does indeed seem to be what is happening.

In order to test the theory, I installed WICD instead, as I have in the past, and once again WICD fixed the problem. I’m not sure why the WICD team just seem to be able to get wireless to work where Network Manager boys persistently struggle, and WICD lacks the additional functionality of 3G connection management, but it just bloody works and that’s the most important feature of a connection manager.

I’ve been using WICD on and off for some time, and I’m impressed with the speed it has developed. It also looks a lot slicker than it did in the early days, something that has not gone unnoticed in the Ubuntu camp as it’s now available in the repositories. One command,

sudo apt-get install wicd

now ditches Network Manager and installs WICD. If you’re having problems with the AR5008 in Ubuntu, it’s well worth a try.

Turning Firefox into a web screensaver using a bash script

There’s a little program available for windows that lets you turn your browser into a screensaver, looping through various web content. However, there are 2 things wrong with it. Firstly it costs money. Secondly it doesn’t run on linux.

So what? – we have bash – and after a bit of digging around this morning and combining a few bits and pieces this is my version for Ubuntu :)

Firstly, in order to run firefox full screen we need the AutoHide plugin, which appears to have been written by someone with an interesting sense of humour.

Secondly, a small alteration needs to be made to the  javascript prefs file (.mozilla/firefox/$profile/prefs.js, $profile = your profile). THIS MUST BE DONE WITH THE BROWSER CLOSED as Firefox overwrites the file on shutdown. Add these two lines at the end of the file:

user_pref("browser.link.open_external", 1);
user_pref("browser.link.open_newwindow", 1);

Now that’s done there’s just a little bash script. Feel free to hack but if you improve it please let me know! I just saved the following few lines as a file “Webscreen” in my home directory:

#!/bin/bash

remoteclient=$(find /usr/lib/ -type f -name mozilla-xremote-client | grep -m 1 xulrunner)

if [ `ps -e | grep firefox | wc -l` -eq 0 ]; then

    /usr/bin/firefox -fullscreen &
    sleep 5

fi

while [ `ps -e | grep firefox | wc -l` -gt 0 ]; do

    urls=$(cat /home/huff/Desktop/pages)

    for i in $urls
        do
        $remoteclient -a firefox "openurl($i)"

        if [ $? -gt 0 ]; then
            echo "Firefox not running or ignoring me, bailing out...."
            killall firefox
            exit 0
        fi
        sleep 15
        done
done
exit 0

Note the path to the mozilla-xremote-client – this is correct on Ubuntu Jaunty but I had to use find to well, you know, find it:

find /usr/lib -iname \*mozilla-xremote\*

As can be seen the script takes the pages you want to cycle through from a text file called (I felt quite pleased with this) “pages” on the Desktop, one url on each line such as:


http://bbc.co.uk
http://flickr.com
http://yoursite.whatever.com

and scrolls through the selection every 15 seconds.

The last detail is to

chmod +x ~/Webscreen

and add a Custom Application Launcher to the panel. Thanks to mozilla for continuing the command line options started by Netscape and the cool AutoHide plugin, this was pretty easy. Hope it helps someone.

Gedit document words autocompletion plugin

Gedit autocompletion plugin in action

I followed a submission to reddit the other day highlighting a few choice plugins for gedit, as I am fond of using the default GNOME text editor. One plugin in particular caught my eye, the document words autocompletion plugin, written by Perriman. Retyping my inventive variable names (not to mention the oft flowery default php function names) is both error-prone and onerous and this plugin is the perfect remedy.

The following applies to Ubuntu Intrepid. I’m using 64 bit, but there’s no difference for 32 bit.

The plugin is not packaged in with the gedit-plugins package and needs to be compiled. It depends on quite a few packages. I chose to cheat a little when installing the required development libraries by first installing the build dependencies for gedit itself. If you haven’t already installed it, the build-essential package will install the most commonly used compilation tools too:

sudo apt-get install build-essential
sudo apt-get build-dep gedit gedit-plugins

Then download the source. The document auto completion plugin depends on Perriman’s gtksourcecompletion, which also needs to be compiled first. The source is available from this Sourceforge page.

Once extracted and in the directory:

./configure --prefix=/usr
make
sudo make install

The plugin itself is also on Sourceforge, the 0.51 version is now on the download page.  Again, once extracted and in the directory:

./configure --prefix=/usr
make
sudo make install

and assuming there are no errors, the plugin should appear in the gedit plugins list (Edit > Preferences > Plugins). Now all I need to do it try to train my left hand pinky not to keep stabbing the tab key for autocompletion!

PHP class using Imagick – resize, reflect or drop shadow

Imagick used to generate reflectionI’ve been spending a bit of time getting to know PHP classes over the Christmas holiday, and I’ve written a couple to test out my knowledge.
The first is an image uploading class, which checks for various problems with files prior to moving them to a destination directory. It checks:

  • that the file actually exists
  • the size to ensure it doesn’t exceed a predetermined maximum
  • that the destination directory exists and is writable
  • that the file is actually a photo file
  • to see that the photo is in an accepted format (tif, jpg, gif, png)

before moving the file. The next class gives various options for manipulating the image, resizing, rounding corners, adding a reflection etc. all using the Imagick class, which is installed with php5-imagick (available from the ubuntu repos and other reputable linux software emporiums!). The reflection and drop shadow parts of the class owe a great deal to Mikko Koppanen who provides some great Imagick examples and code snippets on his blog. I’ve uploaded the classes, including an index file that can be used as an example in the absence of proper documentation!

I’ve uploaded a working version of the test files shown below as a demo to a website of mine: try it here.

Available to dowload as a zip archive including the four empty directories the example script needs to run. Any suggestions for improvement gladly received.

Nvidia 180 on Ubuntu Intrepid Ibex

EDIT: It seems the packages needed are in Intrepid updates now, so as long as they are enabled in System > Applications > Software Sources they should be installed with a simple sudo apt-get update && sudo apt-get install nvidia-glx-180

As a long-time (since Gutsy) follower of Ubuntu bug 99508, Gnome-terminal showing titlebar problems the one about the badly drawn window decoration (see right), I was thrilled to see that Nvidia’s 180 Beta driver fixed the problem. The driver is packaged up and available in the alpha of Jaunty’s next release, 9.04. However, running the alpha as your main OS is folly, not to mention a pain in the butt if you just want to get something done and it’s a bit broken at that moment.

One can always install nvidia’s driver from a shell using the installer provided, but I’m always happier using a .deb, and luckily the 180 debs are coming to Intrepid’s backports. Just not yet. So if you want to try the 180 driver, you can use the Jaunty .debs.

compizI’ve tested it on my laptop under Intrepid, with its integral Nvidia 6100 Go chipset, and it works very well. Some Jaunty testers have reported increased temperatures and odd black spots, but all is ok here. In fact I ran a full screen video on each desktop under compiz (left) without issue.
The debs are available from the Jaunty repos, and the packages required are nvidia-glx-180 and nvidia-180-kernel-source. At present, these contain the 180.11 beta driver – there is a newer one available from nvidia and no doubt the packages in the Jaunty repos will be updated shortly. Once downloaded, a few commands (i386 users will need to alter the architecture part of the filename):

sudo apt-get remove nvidia-glx-177
cd Desktop (if this is where the debs are)
sudo dpkg -i nvidia-180-kernel-source_180.11-0ubuntu1_amd64.deb
sudo dpkg -i nvidia-glx-180_180.11-0ubuntu1_amd64.deb

And a reboot and (fingers x!) you’re done :)

How good is Ilford XP2?

I’m a very amateur photographer – I like the results of taking photos enough to have developed an interest in the process. To this end I still use a 1970s vintage Pentax MX, which has forced me to learn a little something about the interaction of shutter speed, aperture and film choice.

I use Kodak colour slide and print film predominantly, and a couple of years ago I bought an Epson Perfection V700 scanner so I scan directly from the film. My results have been mixed: sometimes I feel the film is just too grainy, and the scanner simply not sharp enough, but I have also been quite pleased with some shots and I am now at least more in control of the post-processing. Tesco will develop a 36 exposure film for only a pound, and the 7dayshop sell film at pretty reasonable prices which makes experimenting a fairly inexpensive pastime.

I have tried Ilford XP2 a couple of times in the past, and been pleased enough with the results, but a recent roll I shot seemed very grainy. On closer inspection, it seems that the film is the most grainy when underexposed. The shots that looked the worst were taken indoors in artificial light, when the aperture was wide open and shutter speed down at about 1/60:

A shot on the same roll of film of my aging Audi in a snow shower, taken in reasonably bright daylight, shows no real grain at all:

So whilst I’m a touch disappointed with the grain on the indoor shots, it would seem that I need to treat the film as a 200 speed indoors in order to make sure it’s fully exposed. Bruce Robbins, on his blog Pentax Photography, discusses the intricacies of scanners and graininess, and as XP2 is a chromogenic film it should be less susceptible to the effects of grain. Other photographers have waxed lyrical on the forgiving nature of XP2 when overexposed. I’m now keen try another roll.

No! Please don’t do it!

There are some highly entertaining examples on the net of command line program output, but it’s great when you’re doing some system maintenance in Linux on your own machine and a gem unexpectedly crops up:

:~$ sudo /etc/init.d/dovecot restart
[sudo] password:
* Restarting IMAP/POP3 mail server dovecot
Warning: Last died with error (see error log for more information): Time just moved backwards by 11 seconds. This might cause a lot of problems, so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards

NO! Please, it’s not worth it! :)

Synaptics touchpad, SHMConfig, xorg.conf and Ubuntu Intrepid 8.10

EDIT – Please note that this post only refers to the 64 bit version of Ubuntu.

Some significant changes have been happening to the X server over the past couple of releases of Ubuntu. One of the most noticeable alterations has been the removal of the xorg.conf file from the default Ubuntu install (edit – it was removed during the development cycle but reappeared in the release version).

It is a great thing that X is now at the stage where it knows devices well enough to configure them with no user input, but occasionally a device may be incorrectly set up, or one may want to customise beyond default settings.

Such is the case with my synaptics touchpad. I really like the fact that in Linux I can configure the touchpad to trigger a middle mouse button event when it is tapped with 3 fingers. Left click – one finger, right click – two fingers, middle click – three fingers. In addition, I want to be able to disable the touchpad while typing.

Read More »