Archive for the 'linux' Category

Live from Hardy Herron

Sunday, April 27th, 2008

Yesterday seemed like as good a time as any to actually do the upgrade to Ubuntu 8.04 on my laptop. A series of wireless card crashes got me fed up to the point that I had to do something.

The upgrade, via update manager, only had one hitch, when the wireless card bonked out in the middle of it. I suppose it adds appropriate insult to injury, given how often the iwl4965 crashed on my over the last couple of months. Resuming the upgrade on wired ethernet, and all was well.

The Good

Upgrade went flawlessly; fonts look even better; wireless seems better; ssh-askpass now seems to actually trigger on login; firefox 3b5 is fast; liferea is much faster

The Bad

Pidgin 2.4’s usability improvements are anything but; A few of my firefox plugins (delicious links, firebug) don’t work with firefox 3b5 yet (as such, my daily links won’t be on the blog until delicious gets fixed).

The Amusing

During installation some 3rd party packages were removed, including Lotus Notes. While I appreciate Ubuntu’s attempt to make my life better, I sorted of need that for work. ;) I’m pulling from our internal repos now.

Popularity: 24% [?]

Beware the Anti-Market

Wednesday, April 2nd, 2008

A vendor can often be their own worst competition if they create good technology, but put it out in a way that is too limiting, in platform support or licensing, than their prospective users would like it to be. I’ve often refered to this as the Anti-Market among colleagues. The rules of the Anti-Market are more or less as follows:

If you create a technology that is useful, but 90% of your prospective market can’t use it for various reasons, they’ve got a good chance of getting together and writing a replacement for your product.

Example 1: KDE vs. Gnome

Gnome created out the anti market that KDE created. KDE is built on QT. Back in the early days of KDE, QT was licenced in rather funny ways by Trolltech. The funny license meant that Red Hat (and other Linux distros) didn’t want to ship it. Mandrake was originally just Red Hat + KDE to fill such a need. But with the bulk of the KDE user market blocked because of bad licencing, a void existed to be filled. Gnome did that. A decade later Gnome is the primary desktop environment on nearly ever major distro, and while KDE 4 has gotten some recent press, it is definitely now a minority player.

KDE was brought down because it created an anti market. People wanted that kind of function, but the way it was delivered was not acceptable to its users.

Example 2: Java vs. Mono on the Linux Desktop

How many Linux desktop apps are you running right now, or ever, that are Java based? How many that are Mono based? The only Java apps I run on the desktop in any frequency are Azureus and Freemind. On the Mono side F-Spot and Tomboy have seen a lot more use. Until very recently Java remained under a license that made including it with the Linux platform quite an issue. Mono is under an MIT license, and has been since day one. While Mono has a number of short comings, the fact that it’s so young, and so much more used than Java in the Linux desktop space speaks a bit to the anti-market that Sun created by waiting forever to open source their baby.

Example 3: MySQL vs. everyone else

In 1995 Linux was already being used to run key parts of the internet. None of the traditional ISVs were paying attention to it (DB2 showed up in 1998 on Linux, and too my knowledge, was the first big database vendor there). You know what you need to run the internet, a reasonable database. MySQL popped out of the anti-market created by there being a platform people were using quite a bit, but lacking ISV support. People needed the function, but couldn’t get it even if they wanted to pay for it.

I continue to be amazed at how much of an anti-market MySQL took advantage of.

Closing thoughts

The Linux Desktop space is full of anti-market applications, some of which have even seeped back into the Windows world, like OpenOffice, Gimp, and Pidgin. Adobe just made a very astute move and got Air out for Linux before they forced a new anti-market there. While the Linux Desktop space isn’t the highest volume space for users, the developer to user ratio in the space is very high, which means ignoring it means there is a real chance of creating an anti-market.

I’d love to hear other people’s thoughts or examples here, comments are open, have at it.

Popularity: 82% [?]

Upgrading my Linode to Xen

Friday, March 28th, 2008

I just did the upgrade of my linode (which hosts mhvlug.org, planet opensim, dague.org, and a few other sites) to Xen. I had put in the request to join the beta for Xen a couple weeks ago, got in, and was slow on my side to actually kick off the migration (which was painless, but required about an hour of down time). It turns out that all of linode is now going to Xen. Based on very simple latecy tests, the box feels much snappier on serving up wiki pages.

Popularity: 78% [?]

The Year of The Linux Desktop?

Sunday, February 10th, 2008

Like all previous years, this year probably isn’t any different, and it won’t be the break out year for Linux on the Desktop.

But…  (there’s always a but).

Something interesting happened over the last year.  People I never expected to be Linux users have installed Ubuntu.  My sister in law and nephew both count in this list.  At some level “regular folks” have now come to Linux.  I have no idea if this is a trend or not, but I find it interesting regardless.

Popularity: 14% [?]

Single sided printing of postscript in Linux

Wednesday, January 9th, 2008

While I appreciate the environmental gains from every Linux system I’ve used in the last couple of years defaulting to double sided printing, this gets a bit annoying when you need single sided pages for doing code refactoring.

I found today that if I loaded up a double sided postscript file into evince (gnome’s pdf / ps viewer), and told it to only do single sided printing, it did as I said.  It took me this long to figure this out, so hopefully this post saves someone the trouble.

Popularity: 9% [?]

More fun with dbus

Sunday, December 2nd, 2007

Since my dbus post last week, I’ve been playing around more with dbus whenever I get a few minutes. The modern Linux desktop is pretty good, but with minor tweaks, you can make things even better. (all this code is now up in a mercurial repository called dbus-hackery).

Automating Inactivity

Pidgin makes sounds on every message to me, xchat makes sounds on certain key words. Without these cues, I’d never remember to go check these applications. Because I have a tendency to leave my laptop on overnight, I found that I’d often have xchat ringing away at midnight when someone was looking for me. If I forgot to mute my machine before that, it would often wake me up.

One of the programs sending signals on dbus is gnome-screensaver.

def connect_screensaver(session_bus)
    ss_dbus = session_bus.service("org.gnome.ScreenSaver")
    ss = ss_dbus.object("/org/gnome/ScreenSaver")
    ss.introspect
    if ss.has_iface? "org.gnome.ScreenSaver"
        ss.default_iface = "org.gnome.ScreenSaver"
        puts "Connected to screensaver"
    end
    return ss
end

def mute()
    IO.popen("aumix -vq") {|r|
        r.read.scan(/(\d+)/) {|m|
            @@vol = m
            puts "saved volume: #{@@vol}"
            break
        }
    }
    puts "muting"
    system("aumix -v 0")
end

def unmute()
    puts "unmuting"
    system("aumix -v #{@@vol}")
end

ss = connect_screensaver(session_bus)

ss.on_signal("ActiveChanged") {|s|
    if s
        mute
    else
        unmute
    end
}

The connect will look exactly as expected from the previous look at dbus. The ActiveChanged signal outputs a single parameter, a boolean, which is true when the screensave goes active, false when the screensaver is deactivated.

Volume control on the command line is most easily done with aumix (though if you are on Ubuntu Gutsy you’ll have issues until you rebuild aumix yourself. Hopefully they’ll fix that bug soon.) A little regex fun captures the current levels to a package variable, and restores them back on unmute.

Now I’ve got global mute when the screensaver fires, restored when I return.

Better Away with Pidgin

My screensaver being locked is a pretty clear indication that I’m away, though it being unlocked isn’t a clear indication that I’m back. Especially on weekends, I pop back for a quick check of something, then the computer is put away again.

def set_away(pidgin)
    puts "trying to set away"
    name = "screensaver"
    status = pidgin.PurpleSavedstatusFind(name)[0]
    if not status > 0
        status = pidgin.PurpleSavedstatusNew(name, 5)[0]
    end
    puts "Status #{status}"

    pidgin.PurpleSavedstatusSetMessage(status, "screen saver auto away")
    pidgin.PurpleSavedstatusActivate(status)
end

ss.on_signal("ActiveChanged") {|s|
    if s
        mute
        set_away(pidgin)
    else
        unmute
    end
}

In order to set a status with a message, it has to be a saved status. To prevent growing that to infinity, I first look to see if it is defined, creating a new saved status if not. 5 is a magic number here meaning STATUS_AWAY (reference the pidgin status.h for more info). Then we set the message on that status, and activate it. A single line change on our screen saver signal adds this into play.

Keep on Hacking

One of the things I’m hoping to impress in these posts on dbus is that with a highly functional language like ruby, linking applications on a modern gnome desktop can be done even by mere mortals. Linking sound to your screen saver is something that would have required a reasonable chunk of c code. Now you can do it in 20 lines of ruby, thanks to dbus.

I’ve thought about creating some sort of extended control panel to enable the features I’ve hacked together, but the reality is the code is so small, and so simple, it seems like overkill. With code this easy, you should just jump in and hack it to your own needs.

As I keep playing with dbus, I’ll post more bits here. Twitter integration is still on my list of things to do, and maybe something I’ll even manage to get to this week.

Popularity: 24% [?]

Ubuntu Packaging Quirk

Saturday, December 1st, 2007

Note to Interwebs:

If you are looking for man pages for built in functions like printf, they aren’t in the manpages package, but instead in the manpages-dev package.  Go figure.

Popularity: 12% [?]

Pidgin, Network Manager, Dbus, Ruby, oh my!

Sunday, November 25th, 2007

A few weeks ago I was chatting with Dan about my one great annoyance with Pidgin: it takes up to 15 minutes to realize that it’s network connection isn’t valid any more and to automatically reconnect. With NetworkManager and dbus, this should be a reasonably simple feat. Dan got curious about this and wrote himself a python program that sets pidgin status in this way.

D-What?

A bit of background. One of the Freedesktop.org standards is d-bus:

D-Bus is a message bus system, a simple way for applications to talk to one another. In addition to interprocess communication, D-Bus helps coordinate process lifecycle; it makes it simple and reliable to code a “single instance” application or daemon, and to launch applications and daemons on demand when their services are needed.

The basic idea is that d-bus allows applications to publish interfaces that other applications on the desktop can interface with. Right now, only a few applications really support d-bus in a significant way. Fortunately, one of those is pidgin, which has an extremely rich d-bus interface.

Ruby & DBUS

Here’s a place where I know I’ll draw Dan’s ire. I’ve been on a Ruby kick recently, so my first reaction to Dan’s post was “great, I’ll have to figure out how to do this in ruby now.” It sounds like typical language bias, but I’ll try to justify it at least a little.

Right now I’m writing code on a weekly basis in 3 languages: C# (OpenSim), Java (Grad School Project), and Ruby (side web projects done in Rails). 3 languages is a lot to remain fluent in, and causes some interesting syntax errors when jumping back and forth between them. One less context switch seemed like a good idea. At some point I’ll bother writing up why ruby has seduced me, but that is for another day.

While finding python-dbus bindings are extremely straight forward, the ruby-dbus front is a little more of a wandering path. After finding a couple of abandoned efforts, I finally came to the active ruby-dbus project. Make sure to grab the latest and greatest code from there before proceeding.

Connecting to DBUS

Before I get into actually using dbus, I need to set up connections to it. There are 2 different buses, the system bus (which is shared for all users), and the session bus, which is unique per login session. Pidgin uses the session bus: it’s a user application. Network Manager uses the system bus: it’s events are system wide and affect all users.

#!/usr/bin/ruby

require “dbus”

bus = DBus::SystemBus.instance
session_bus = DBus::SessionBus.instance

# Get the Pidgin Service
pidgin_dbus = session_bus.service(“im.pidgin.purple.PurpleService”)

# Get the object from this service
pidgin = pidgin_dbus.object(“/im/pidgin/purple/PurpleObject”)

# Introspect it
pidgin.introspect
if pidgin.has_iface? “im.pidgin.purple.PurpleInterface”
    pidgin.default_iface = “im.pidgin.purple.PurpleInterface”
    puts “We have Pidgin interface”
end

n_dbus = bus.service(“org.freedesktop.NetworkManager”)
netman = n_dbus.object(“/org/freedesktop/NetworkManager”)
# Establish a proxy interface object for NetworkManager as it doesn’t support introspection
poi = DBus::ProxyObjectInterface.new(netman, “org.freedesktop.NetworkManager”)

Basically the pattern is clear. Get a service handle, get an object definition from that service handle, then get an interface from that object. There are 2 flavors for this, one where we’ve got introspection information, and one where we’ve got to go blind because introspection isn’t supported.

DBUS Introspection

DBUS interfaces come in 2 flavors, those that support introspection, and those that don’t. If an interface supports introspection you can get an interface definition off the dbus wire itself, otherwise you need to know the interface a priori. Pidgin supports introspection, Network Manager does not. The major short coming of the ars technica article on Pidgin and DBUS was the lack of information on using introspection to show all the other pidgin interface functions (of which there are > 600). Python dbus introspection throws an exception on my Ubuntu 7.10 environment, so it wasn’t helpful here. However, ruby, as usual, came to the rescue.

The ruby-dbus code contains an example application called gd-bus, which performs introspection on all dbus interfaces it can find, and prints them out nicely. The cheat sheet goes something like so:

M PurpleAccountsFind(in name:s, in protocol:s, out RESULT:i)

  • M - DBUS Method, aka Function (might also be S meaning it’s a Signal you can register to listen to)
  • PurpleAccountsFind - the method name
  • in / out - whether this is an input or output parameter
  • NAME:type - the name and type of the parameter. Types can be s - string, i - integer, u - unsigned int, ai - array of integers

Note: the ruby interface seems to always wrap arrays around the output parameters. I have no idea why, but it’s consistent, so a few extra “[0]“s get you a long ways. If you know why, please comment.

The translation of this interface specification into ruby gives you something like this:

def recycle_pidgin(pidgin)
    accounts = pidgin.PurpleAccountsGetAll
    for account in accounts[0]
        if pidgin.PurpleAccountIsConnected(account)[0] > 0
            pidgin.PurpleAccountDisconnect(account)
        end
        pidgin.PurpleAccountConnect(account)
    end
end

This cycles through all pidgin accounts, disconnects all the connected ones, and then attempts to connect all accounts. This is effectively what I end up doing by hand every time I switch networks with my laptop.

Bringing it all together

I now had connections to the 2 buses, and code to cycle the pidgin accounts. Last bit is actually watching for the Network Manager signal that I’ve got a new active network device.

poi.on_signal(bus, "DeviceNowActive“) {
    recycle_pidgin(pidgin)
}

main = DBus::Main.new
main << bus
main.run

Network manager doesn’t support introspection. However, it does have pretty decent docs to figure out what the interface is. I’m still sad it doesn’t show up nicely in gd-bus though.

The proxy interface object sets up a signal using 2 parameters and a code block. Every time there is a DeviceNowActive signal on the system bus, I recycle pidgin. Pretty straight forward.

The last little bit is making this thing go into a loop. Ruby dbus contains it’s own main loop for just this task. I created a new main loop, tell it to watch the system bus, and then start it. And, we’re done.

The future’s so bright…

DBUS has been on my list of “I need to go figure this out” for a while. A morning of reading docs, hacking a bit, and crashing network manager a few times, and voila, you’ve got this blog post.

I’ve got lots of ideas floating around in my head now for other things that I can do with dbus to make my applications work better for me. As I bang a few of those out into code, expect to see more here about it. Pidgin is an especially target rich environment given how rich and interface they expose (nice job guys!).

Popularity: 25% [?]

Linux native Logitech Harmony software

Wednesday, November 21st, 2007

While looking for a solution to my VMWare / USB issue, I came across a Linux.com article:
Developer crafts Linux support for Logitech Harmony remote controls.

Instead of using the Windows GUI to program the remote, you use the Logitech website (the windows gui is basically a fancy version of that). When you are done, you download a .EZHex file which you can then sync in Linux to your remote.

I haven’t tried it yet, though it is on my list of things to do. For those who have stayed away from the Logitech Harmony remotes because they required Windows, you need no longer live in the dark ages of remote controls.

Popularity: 15% [?]

USB Passthrough with VMWare and Ubuntu 7.10

Wednesday, November 21st, 2007

While I don’t run windows on any physical hardware, I have a VMWare windows xp guest on my laptop that I use for a couple of applications. One of which is the programming software for my Logitech Harmony remote.

In my recent laptop update to Ubuntu 7.10, VMWare Server lost the ability to pass through the USB bus to the guest. Fortunately, a quick search on the VMWare forums came up with the following:

Please open the following file: /etc/init.d/mountdevsubfs.sh by following command - gksudo gedit /etc/init.d/mountdevsubfs.sh

Find the following lines:
#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount –rbind /dev/bus/usb /proc/bus/usb

Unmark them so that look like this:
mkdir -p /dev/bus/usb/.usbfs
domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount –rbind /dev/bus/usb /proc/bus/usb

Restart and your usb devices will be recognised

This worked like a champ, and now I can do the rest of my pre thanksgiving tweaks on the remote. :)

Popularity: 13% [?]