Meet GMenu, Sibling of DMenu

I have been using wmii for quite some time now and right now can’t think of ever using a non tiling window manager ever again. Before wmii I tried dwm but didn’t quite like it as much as wmii.

But what I liked most about dwm and wmii is their “application launchers”: wimenu and dmenu. Actually they’re not really application launchers. All they really do, is read a list of items from STDIN and pop up a window where you can search and select the item you want. This (or whatever you typed) is then printed on STDOUT. It’s really trivial to create an application launching utility from these, basically just pipe ls /usr/bin to one of them, and then execute the resulting string. And did I mention they are both fast? Well, they are!

But they are also limited in ways I didn’t like. Wimenu displays it’s window either at the top edge or the bottom edge of the screen, and it displays the items in a horizontal list. Dmenu is similar, though it can display the items vertically, it will still span the whole screen width. I find horizontal lists hard to read, I prefer vertical lists. And while Dmenu can satisfy that, I would still prefer the window to be centered on the screen, a region I look at most of the time.

I spend some time reading the code of wimenu and dmenu, considering hacking them. But in the end, I decided against it. Both are written in plain C, no toolkit used, just basic Xlib. For the features I wanted to add, it was clear to me I would spend quite a bit of time implementing half a gui toolkit before I could even get to coding my desired features. And that’s when I decided to use GTK for my application, and hence I called it gmenu (as unimaginative as that is.)

You can check out gmenu at github.


One Response to Meet GMenu, Sibling of DMenu

  1. Anonymous says:

    This is useful for integrating a better menu if stuck with using GTK. The only thing is it doesn’t handle mouse button presses, which is to be expected when the environment is based on GTK. Thanks

    --- gmenu.c.old 2010-12-05 07:51:48.000000000 -0600
    +++ gmenu.c 2010-12-05 07:53:45.000000000 -0600
    @@ -175,6 +175,17 @@
    return FALSE;

    +static gboolean entry_on_button_press
    +( GtkWidget *w, GdkEventKey *e, App *app )
    + if (e->type == GDK_2BUTTON_PRESS || e->type == GDK_3BUTTON_PRESS) {
    + print_result( app );
    + gtk_main_quit();
    + return TRUE;
    + }
    + return FALSE;
    static void selection_changed
    ( GtkTreeSelection *sel, App *app ) {
    GtkTreeIter i;
    @@ -316,6 +327,11 @@
    gtk_tree_selection_set_mode( sel, GTK_SELECTION_SINGLE );
    g_signal_connect( G_OBJECT(sel), "changed",
    G_CALLBACK(selection_changed), &app );
    + g_signal_connect( G_OBJECT(app.tree_view), "key-press-event",
    + G_CALLBACK(entry_on_key_press), &app );
    + g_signal_connect( G_OBJECT(app.tree_view), "button-press-event",
    + G_CALLBACK(entry_on_button_press), &app );

    gtk_container_add( GTK_CONTAINER(swindow), app.tree_view );
    g_object_unref( G_OBJECT(app.filter) );

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: