High forked-daapd cpu usage?

So there I was playing with Rhythbox and bemoaning the non-existant DLNA support when I noticed (even though it’s always been there) the DAAP plugin. “What is this DAAP of which you speak?” I thought, and ended up installing mt-daapd. Turns out DAAP is rather good, and there’s even a very useful Android app for it, so I’m quite keen to continue with it.

Now mt-daapd hasn’t been maintained for years, and according to the man who forked the project and created (by his own admission) the terribly named forked-daapd you’d need to be a confirmed stick in the mud to continue using the older version. And as forked-daapd is in the Ubuntu Precise repositories, it got installed. Initial tinkering showed positive signs of life so I left it doing it’s thing and went to bed.

The following morning as I padded into the lounge I noticed the normally quiet fan on the media server sounding quite breathless, and one htop later could see the cpu at 100%. A quick

ls -l /proc/`pidof forked-daapd`/fd

showed forked-daapd holding open a Microsoft Word document. I ran a

find /media/music -name \*.doc -exec rm {} \;

(don’t run this on your home dir) to blitz any .docs in the music directory and restarted forked-daapd (in fact I had to kill -9 the daap server as it was still avidly reading the Word doc). I had to run through a similar process with some old Thumbs.db files that forked-daapd wouldn’t parse or let go of, but all now appears well.

So in conclusion, if you’re running forked-daapd and it’s pegging your cpu at 100% for a long time, check which files it’s holding open. Naturally unlike me you won’t have a music folder full of junk.

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 :)

FirstClass. On 64 bit AMD64 Ubuntu.

For my OU course in Web Applications Development, I have to use a piece of software called FirstClass, from OpenText. Thankfully the nice people at OpenText have packaged up a version for Debian and Ubuntu, version 8.315-2 (one major release behind Windows admittedly, but perfectly usable). If you’re using a 32 bit version the install couldn’t be easier.

However, I switched to 64bit Linux some time ago now. After emailing OpenText to see if they will be compiling a 64 bit version and receiving a positive negative, I’ve discovered a quick and simple way to get it working without leaving a mess of libraries.

(more…)

Amarok, Ubuntu Gutsy 7.10, Bluetooth and Sony MBR-100 Audio Receiver

As we all know Amarok is the best music player in the world, and it’s free. It’s only available on Linux at the moment but the devs are working hard to port it to Windows. Anyway I digress. I wanted to explain how I got Amarok playing on my laptop, accessing my music collection on my media server, through my bluetooth dongle, picked up by my Sony MBR-100 bluetooth audio receiver and finally terminating joyfully in my trusty Sennheisers.

(more…)

RT73 on Ubuntu 8.10 Intrepid Ibex

If you’ve used the Ralink RT73 chipset under Ubuntu for any length of time, you’ll know that the default drivers aren’t yet perfect (some supporting evidence). Some may have had more success, but in my experience they drop out regularly and transfer rates are pretty mediocre. The modules used are the rt2x00usb and rt73usb. These are the next generation of Ralink drivers from Serialmonkey, and to be fair they have improved a great deal over the past couple of years. However, there is a more stable driver, which, although requiring some sacrifice, rewards the user with good injection support, great transfer speeds and no drop-outs.

Step forward the rt73 legacy driver….
(more…)