Dedicated to my late brave, beautiful and silly mummy, Debra Ross. I love you mumster.

Skip navigation

Category archive for how-to

Because archives are so much easier than having just hundreds of posts on the home page. I learned that the hard way.

Fun with the Mac OS X weather widget

While rearranging my Dashboard widgets on my MacBook Pro this morning, I accidently stumbled upon a feature in the Weather widget which upon later investigation has already been well documented. At least I felt like an electronic archaeologist for a few minutes!

Regular Dashboard widget showing weather in Mawson Lakes, South Australia
Regular Dashboard widget showing weather in Mawson Lakes, South Australia

If you haven’t tried this out already though, give it a shot:

  1. Fire up your Dashboard, usually with the F12 key
  2. Drag a new Weather widget from the widget bar onto the Dashboard
  3. Hold down the Command/Apple and Alt/Option keys

You now have a widget with the weather set to "Nowhere", and by clicking the picture in the top centre you can change the weather conditions. It was cold and raining before in Rubenerd Nowhere, now it’s snowing!

Altered Dashboard widget showing rain in Nowhere

Altered Dashboard widget showing snow in Nowhere

VIDEO: Replacing the fan in my MacBook Pro

For about a year now my MacBook Pro exhibited horrible grinding, rattling sounds on the right hand side of the unit, just below the power button. After doing a bit of research I realised that I had a damaged fan (Apple unit number 922-7194), and while I could have tried lubricating the existing one, I decided to play it safe and just buy a replacement. PBParts.com had the best overall price for the unit and international shipping to Australia, and had the unit to me in less than 2 weeks with economy mail.

Rather than take photos as I usually do for such projects, I decided to edit together a crappy little video showing what I did, and so you could hear the difference yourself! I just can’t believe how whisper quiet this MacBook Pro is again, I literally cannot hear it unless I turn off every other appliance and peripheral in the room!

Apologies to my readers on BSD, alas because my current host’s bandwidth quota is almost used up, I’ve had to uploaded the video on YouTube.

Western Digital MyBook DHCP adventure

Before I go any further, I’d like to warn you that this post about using FreeBSD to assign an address to a Western Digital MyBook drive is unnecessarily verbose. See, I could have just as easily said "this post is long".

Writing about theoretical uses for software is one thing, but figuring out how to apply software to a problem practically, and actually getting it work, is one of the greatest feelings in the world alongside writing a fantastic piece of software yourself to solve a problem. It makes me feel useful and gives me a rush quite unlike anything else.

And he’s available ladies! Unbelievable though it may seem! Come on! He also makes a mean Earl Grey latte. Any bidders? Anyone?

Case in point, my sister and I had a problem in our new house in Adelaide. Before I left Singapore, I bought a gigabit ethernet Western Digital MyBook 1GB World Edition NAS drive and loaded it up with all our media: movies, shows, music, podcasts, BSD disk images, ebooks. By using a simple network drive, we spared ourselves having to bring a separate computer down with us.

Our makeshift home network consists of each of our laptops and the aformentioned network drive which are all connected through short Cat-6 ethernet cables to a 5 port gigabit ethernet switch. To compensate for the lack of a router, I assigned my sister’s MacBook and my MacBook Pro static IP addresses and I knew the network drive could also be assigned one. Very cool.

Our very fancy new home network
Our very fancy new home network.

Now here’s the kicker: for some reason in their infinite wisdom Western Digital decided not to ship the MyBook with a default IP address. This means it requires a DHCP server (Wikipedia link) to initally provide it with an address. I realised that without a router with a built in DHCP server, this network drive wouldn’t get an address, and therefore there’d be no way for me to log into it to assign it a static IP! Catch 22, chicken and the egg, a Bruce Schneier fact, call it what you will.

So within a few minutes I had configured a home network with two laptops and an inaccessible, address-less network drive. It seemed not having a router with a built in DHCP server would make this setup impossible. A quick Perl script determined that indeed only the two laptops were in our subdomain range:

#!/usr/bin/env perl

for ($i = 1; $i < 255; $i++) {
  system “ping -a -c 2 192.168.1.$i”
}

print "Western Digital engineers love DHCP it seems\n";

At this point I had to make a tough decision. To access our media network drive I could either be patient and wait a week until we got our new broadband modem with a built in router, or I could be impatient. Grilled cheese sandwich. Grillec cheese sandwich?

I decided to do the latter and give it what it wanted: a DHCP server! In place of a router, I would configure a one-time use FreeBSD virtual machine with a software DHCP server which would assign the address to the network drive, so I could log into it remotely and assign it a static IP.

My FreeBSD virtual machine showing the DHCP server coming online
My FreeBSD virtual machine showing the DHCP server coming online

After setting up a generic VMware Fusion virtual machine on my MacBook Pro, I mounted a FreeBSD 7.0-RELEASE ISO I had on already had on my hard drive and installed it with all the default options. I skipped configuring everything in the system installer except than the network card. I declined to use DHCP when it asked, and assigned it a static IP.

After rebooting the VM, I logged in as root and installed the isc-dhcp3-server package from ports.

I didn’t bother adding anything fancy to the /usr/local/etc/dhcpd.conf other than defining the pool of addresses and required options:

option domain-name "chuckpeddle";
option subnet-mask 255.255.255.0;

default-lease-time 3600;
max-lease-time 86400;
ddns-update-style none;

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.120 192.168.1.129;
}

Next, to check what addresses our makeshift DHCP server has assigned, I created the default dhcpd.leases file:

# touch /var/db/dhcpd.leases

Finally, I enabled the dhcpd daemon in /etc/rc.conf and told it what card I wanted FreeBSD to listen for DHCP requests on. On VMware Fusion 1.1.3, the network card in FreeBSD is le0, but you can always check to make sure by using ifconfig -a

dhcpd_enable="YES"
dhcpd_ifaces=”le0″

The moment of truth had arrived! I turned off my Western Digital MyBook NAS drive, rebooted the FreeBSD virtual machine, then turned the network drive back on again. After a minute of waiting, sure enough the /var/db/dhcpd.leases file reported that it had assigned an address…

lease 192.168.1.129 {
  starts 6 2008/08/02 14:37:12;
  ends 6 2008/08/02 15:37:12;
  binding state active;
  next binding state free;
  …
  client-hostname “RubenerdNAS”;
}

… and automagically the Finder on my MacBook Pro reported it had found a new samba share (with it’s irreverent sense of humour)! My network drive had been resurrected from the dead!

My Western Digital MyBook in the Finder
My Western Digital MyBook in the Finder

Finally, after all of that I was able to go to my web browser and log into the damned network drive’s configuration page and change the IP address to a static one.

I still can’t help but wonder why Western Digital decided not to include a default address.

Western Digital NAS config screen, and the FreeBSD DHCP virtual machine
Western Digital NAS config screen, and the FreeBSD DHCP virtual machine

And now if you’d excuse me, I’m off to watch an episode of Cranky Geeks. From my network drive. PHEW!

Backing up CDs to ISOs on FreeBSD

I remember back in 1995 when I was 9 years old our family excitedly got its first CD-ROM drive. This was just before we moved to Singapore and were still living in Australia, and that small little Creative Hex Speed optical spinning wonder cost us a small optical spinning fortune. It was proudly installed above the 5.25 inch floppy drive in our generic 486SX PC clone tower. It came with 10 CDs, we had 2 already. I still have that CD-ROM drive.

MENTAL NOTE: Spend less time on the introductions and more on the actual content on the post. Nobody cares about your first CD-ROM drive!

Here we are in 2008 and despite the fact I haven’t toasted or bought a CD for years I’m literally swimming in thousands of them. As a Windows user back in the dark days I remember I used Nero Express to create backup ISOs out of CDs, then either burn those ISOs to a single DVD or store them on a backup hard disk. Fortunately FreeBSD has similar capabilities with the venerable command line dd utility.

Spiffy somewhat related icons from the Tango Desktop Project
Spiffy icons from the Tango Desktop Project

Insert the CD you want to copy (no, really?), then enter the line below. Substitute acd0 with an alternative device if you have multiple optical drives:

# dd if=/dev/acd0 of=[YOUR_NAME_OF_IMAGE].iso bs=2048

This will take some time. Naturally the CPU power your machine has and the read speed of your optical drive will affect performance. A 52x optical drive on my 3.0GHz E8400 Core 2 Duo desktop takes a few minutes, my MacBook Pro a few minutes longer still, I’m sure our family 486 with a hex speed drive would take considerably longer!

For what it’s worth, the same procedure can be used on NetBSD and Mac OS X from my own testing. Just switch the virtual device /dev/acd0 with the relevant line for your OS. Isn’t BSD heritage fantastic? :-)

Tunneling X11 through SSH on Mac OS X

As I increasingly use and rely upon Unix-like operating systems such as FreeBSD (and GNU/Linux) on desktops, I tend to forget at times that I’m using a sophisticated server installed locally to generate my graphical environments, namely X11. And just as with any server I can call it up from another machine and use its services.

X11.app X11 was built specifically to serve graphical applications over networks, and can still be used in this way by employing SSH on the client, and installing the desired applications on the server. My primary desktop is a DIY running FreeBSD 7.0 (more on my debacle with Debian GNU/Linux in a later post!), and my primary mobile machine is an original generation MacBook Pro.

USELESS ASIDE: Given the fact it’s about time for my half-yearly move back to Adelaide, Australia I’ve been contemplating how best to access my desktop machines here in Singapore using my MacBook Pro which I’ll be taking with me. These are the things that keep my up at night.

To access desktop applications on a remote Unix-like machine on your Mac, fire up your Terminal and use the regular SSH command, but with the -X flag:

% ssh -X [USERNAME]@[HOST MACHINE]
% Password: [PASSWORD]

Provided you have installed X11.app from either your Tiger or Leopard install DVD; or better yet downloaded the latest community build of Xquartz from MacOSForge; you should now be able to enter in the name of a graphical application and have it appear!

Tunneled FreeBSD X11 apps on Mac OS X
Tunneled FreeBSD X11 apps running on Mac OS X through SSH

For example, I entered % xfce4-panel and used that to launch some of my favourite apps, as you can see above. Over my local home gigabit ethernet connection and even at Starbucks on the free Singapore public WiFi networks the applications felt like they were running on my local machine.

You may recognise the Xfce panel from my previous post on Xfce and Openbox. There’s a reason for that; I’m using the panel remotely from the same machine. Ain’t [computer] science wonderful?

Plus then you can do things like run local Mac applications and the remote X11 applications on the same screen:

Tunneled FreeBSD X11 apps on Mac OS X
Xfce’s Thunar file manager compared to Leopard’s Finder

Fun with Xfce part 4: Using Openbox

What started as a mini series on the Xfce Desktop Environment on my university intranet has evolved into an open ended exploration on my public blog, and I’m having lots of fun doing it! Scroll down to the end of this post to view links to the previous posts in the series.

Part of the Xfce desktop environment is Xfwm, the Xfce window manager. Xfwm provides sophisticated and pretty composting effects such as drop shadows and alpha transparency on windows and menus, while still using less memory and power than competing desktop window managers. Despite this, for much slower machines even Xfwm can be overkill.

ASIDE: "Window managers" draw the widgets, title bars, resize handles and other elements onto application windows. "Desktop environments" such as KDE, GNOME and Xfce bundle their own window managers along with software developed specifically for their environments, such as Thunar for Xfce.

Enter Openbox, again! Openbox is an extensible, standards compliant, very minimalistic window manager that can be used by itself or in place of a desktop environment’s default window manager to further reduce memory and processor resources. The separate obconf utility provides a nice graphical control panel you can use to switch themes and adjust settings.

The Obconf window and Xfce Settings menu entry
Openbox running in Xfce with the bundled "Mikachu" theme

Most reputable package managers carry both Openbox and obconf, check your distribution’s repositories. To install them on my favourite BSD flavours for example:

FreeBSD ports system or package
# cd /usr/ports/x11-wm/openbox && make install clean
# cd /usr/ports/x11-wm/obconf && make install clean
or:
# pkg_add -rv openbox
# pkg_add -rv obconf

NetBSD pkgsrc
# cd /usr/pkgsrc/wm/openbox && make install clean clean-depends
# cd /usr/pkgsrc/wm/obconf && make install clean clean-depends

Now we want to kill the active Xfwm process in Xfce and open our glorious Openbox replacement. Fire up your Terminal and enter:

% killall xfwm4 ; openbox & exit

It really is smaller in every sense of the word isn’t it? To make sure Openbox is used by default whenever you start Xfce, quit Xfce and check "Save sessions for future login".

The Obconf window and Xfce Settings menu entry
Don’t worry, CC looks pretty confused herself!

You’ll also notice that the "Openbox Configuration Manager" has added itself to the Xfce Settings menu! Click on it and have fun with all the different themes, button positions, font sizes and arrangement settings.

Related posts

Fun with Xfce, part three

This post is part of a series on Xfce, originally posted on my university blog. I’m republishing them here in the hopes that others might find them useful or interesting. Cheers!

In part one of my Fun with Xfce series I talked about why I like using Xfce to begin with, and in part two I explained how to install the complete desktop environment from scratch using FreeBSD ports and pkgsrc, as well as some free GNU/Linux distros that use it by default. In this post I’ll be showing you how I spruce up Xfce to look much more spiffy, learned from many hours of experimentation!

When you run Xfce for the first time, it does look a bit bare. I revel in this; it’s like getting a blank but very flexible canvas to change as I see fit! Assuming you installed the complete desktop using a "meta" package or port, the first thing you can do is browse the built in themes and options. Right click your desktop or click the Xfce icon in the lower dock to bring up the Desktop Menu, then navigate to Settings and click Settings Manager. The control panels you’d be interested in are Desktop, User Interface and Window Manager. They’re extremely well laid out and very self explanatory.

If every computer system had configuration panels that were as intuitive as Xfce’s, I imagine the world would be in a much less stressed place!

Settings windows in Xfce 4.4.2
Settings windows with the default Xfce 4.4.2 themes & decorations

While Xfce does come with a beautiful collection of polished window manager decorations (aka title bar styles), personally I don’t like the built in themes as much and am not a big fan of the lone icon set. Fortunately because Xfce uses GTK+ you can use many of the same themes and icon sets developed for the much larger GNOME desktop with no problems. Kick arse!

First to the themes: personally I like using the Clearlooks theme engine that is used by Ubuntu. It looks very polished and doesn’t have as much of a chiseled look as some of the default themes. In the FreeBSD ports system there are two different versions available which caught me out the first time! Once you’ve installed them, go back to your User Interface settings screen and choose Clearlooks from the list box.

For the fancy version, as famously used in Ubuntu:
# cd /usr/ports/x11-themes/gtk-murrina-fancy-clearlooks
# make install clean
or: # pkg_add -rv gtk-murrina-fancy-clearlooks

For the older, Bluecurve inspired version:
# cd /usr/ports/x11-themes/clearlooks
# make install clean
or: # pkg_add -rv clearlooks

As for icons, I’m a huge fan of Tango Desktop Project who’s stated aim is to "help create a consistent graphical user interface experience for free and Open Source software". The icons they’ve developed look very swish, scale beautifully and use lots of green and blue which I prefer to the default Xfce brown iconset. On FreeBSD you’ll want to grab two Tango ports, then click the Icons tab in the User Interface settings window.

# cd /usr/ports/x11-themes/icons-tango
# make install clean
or: # pkg_add -rv icons-tango

# cd /usr/ports/x11-themes/icons-tango-extras
# make install clean
or: # pkg_add -rv icons-tango-extras

Just by installing Clearlooks and the Tango iconset, you’ll be rewarded with a much prettier desktop!

Before…
Xfce 4.4.2 with Xfce theme and Rodent iconset

After…
Settings windows in Xfce 4.4.2

Okay I cheated in that second shot, I set a desktop background and changed the window decoration to Katiola which blends the menu and title bar to make it look more OS X-ish.

Stay tuned for the next installment.

Fun with Xfce, part two

This post is part of a series on Xfce, originally posted on my university blog. I’m republishing them here in the hopes that others might find them useful or interesting. Cheers!

In my Fun with Xfce part one post I explained that I find Xfce such a pleasure to use because it’s fast, lightweight and has natural visually consistency with my GTK+ apps without the bloat of GNOME, while still providing a cohesive desktop experience with functional applications. In this post I’ll be explaining how to install it.

ASIDE: If you want to give Xfce a try without going through the process of using a package manager and configuring Xorg, the Zenwalk and Xubuntu GNU/Linux distributions have Xfce as their default desktops, plus they have very slick installers and are very newbie friendly.

What’s so liberating about using Xfce as opposed to GNOME or KDE is how lightweight it is and how few dependencies it has in comparison. This is especially noticeable on computers with less storage space, and slower machines which can literally take an entire day to build a desktop environment from source, if that’s your preferred installation method. Of course this means that Xfce is missing some features, but I don’t find myself missing any of them.

Xfce About dialog box, Terminal window showing FreeBSD uname

My experience with package managers are really limited to the FreeBSD ports system and NetBSD’s pkgsrc (on NetBSD and Slackware Linux), so these will be the systems I’ll talk about here. Most *nix package management systems have Xfce though, and most have an easy to install “meta” package that contains the whole desktop.

To install a complete Xfce desktop on FreeBSD (I’m assuming you already have X installed and configured), update your ports tree (visit the Using the Ports System chapter in the FreeBSD handbook if you need help) then compile and install. Alternatively you can install the pre-compiled package which is generally up to date with Xfce’s releases (currently at 4.4.2).

# cd /usr/ports/x11-wm/xfce4
# make install clean
or …
# pkg_add -rv xfce4

On NetBSD and/or if you’re using pkgsrc, the procedure is just as easy:

# cd /usr/ports/meta-pkgs/xfce4
# make install clean clean-depends

Then it’s simply a matter of adding exec startxfce4 to your .xinitrc file in your home directory; create it from scratch if it doesn’t exist. Make sure to comment out any other lines related to other desktops and/or window managers you might have installed (but obviously keep lines you may have added to have X11 applications start automatically when you launch X).

Typing startx at this point will start X and your new Xfce desktop!

ASIDE: If you haven’t aliased your machine’s hostname to 127.0.0.1 in your /etc/hosts file, Xfce will give you a warning message. You can safely ignore it, but it can get irritating after a while! Edit your host file to fix this.

In the next post I’ll be explaining how I pretty up Xfce by adding new themes and icon sets, and how to make it look like other desktops. Stay tuned.

RichardDawkins.net