Archive for the ‘Uncategorized’ Category

Hacking the Unity Shell – An Alternative Apps Lens

Friday, November 4th, 2011

(fret not, this is not only a wall of text, there’s a juicy screencast at the end if you make it all the way)

Me being the maintainer of the applications lens in Unity you might wonder why I am now blogging about an alternative apps lens – let alone why I actually wrote the alternative myself! :-)

I am personally quite happy about the current default apps lens in Unity. It doesn’t try to be too smart, but aims more for the simple and intuitive. That’s why we only do prefix matching on the words in the application, eg  if the user types “term” it matches th word “Terminal”, but not “XTerm”. We also want the matching to be consistent with that of the results coming from the Ubuntu Software Center – which also works with prefix matching.

Not all users find prefix matching to be the best thing since sliced bread. I like it, but astonishingly the whole world doesn’t think like me!? Nonetheless I can respect that :-)

Some users wants to see substring matching which means that “term” matches both “Terminal” and “XTerm”. More progressive users wants a more powerful approach that we can call subpattern matching where the letters in the input string must occur in the same order in the string we test against, eg. “term” matches both “Terminal”, “XTerm” and Television Remote”. This can also be thought of as some sort of “acronym matching”.

Matching algorithms aside some users simply hate to search for their apps and doesn’t like to go digging in the filters we have on the right (the filters are also hidden by default which makes them not so easily discoverable). They want to browse their good olde hierarchical menus.

… some users abhor the Most Used and Downloadable apps categories of the deafults lens – and some users probably want something completely different!

Had I not been an old fart I would probably gladly had added tonnes of options to the unity-lens-applications codebase trying to make everyone happy. But I am an old fart :-) I want a simple and tight codebase and I don’t want tonnes of options because that makes the code harder to maintain. More tricky maintenance means that the ones that are happy with the defaults will suffer.

Enter the power of Unity! You see; Unity is not only a shell in the user-facing kinda way. It is also a shell in the programmable kind of way :-) The default lenses are not hard coded, you can replace them. So you can replace the apps lens as well if you want.

I’ve aired the idea of writing an alternative apps lens numerous times to the ones requesting changes, but none ever appeared that I know of. So I was thinking that I could maybe kick start that effort if I provide a solid starting point. Hence I whipped up Bliss, https://launchpad.net/unity-lens-bliss.

Bliss is a very simple replacement for the apps lens. It does basic searching with substring matching and it allows you to browse your apps by category. It also contains a good collection of bugs, but I’ve been dogfooding it here for a while now and it’s nothing unbearable :-)

Considering the new focus on power users for the Precise cycle I thought/hoped that I could inspire someone to grab the code and write a production ready app launcher specifically tailored for power users. I made the code so that it should be easy to hack on and extend, so let’s see where it ends up…

Caveat emptor: Bliss is by no means official or anything. It is a quick hack to showcase how you can go about this, mostly intended for developers who want to do their own thing. That is also why you wont find a PPA for it (not from me at least :-) ).

Intruding Bliss, an Alternative Apps Lens for Unity from Mikkel Kamstrup Erlandsen on Vimeo.

So branch it, hack it, break, it, fork it. Knock yourselves out!

(I know of at least two obvious bugs: b1) the back arrow sometimes doesn’t appear as the first item, b2) the More Apps shortcut on the dash home screen breaks when you remove unity-lens-applications)

Wonderful Diversity

Friday, October 15th, 2010

Refresh page in Firefox: Control-r

Refresh feeds in Liferea: Control-a

Refresh messages in Gwibber: F5

Refresh inbox in Evolution: F9

I like how my desktop challenges my, otherwise limited, memory. Who knows where I’d be at without the daily exercise? ;-)

Mikkel is Dead, Long Live the New Mikkel!

Saturday, February 20th, 2010

Yesterday was my last day at the Danish State and University Library. What a great time it’s been – but an opportunity even more awesome has presented it self to me; on which I’ll elaborate very soon.

This is Kamstrup, last survivor of the Nostromo, signing off

My time at the library has been awesome. The work atmosphere is relaxed and creative – but with a bunch of top notch people that can really kick into the high gears when needed. If you are a Java developer with a passion for open source and want to hang out with a bunch of top notch code slingers you will feel right at home there – I know i did! :-)

It comes as a surprise to many that the State Library has a small army of computer scientists in their stables – but indeed that is the case. Consider (just some of) the tasks that it’s undertaking:

  • Archiving the Danish internet
  • Digitally recording and archiving all Danish radio and TV
  • Developing a semantic repository for long term preservation of digital objects
  • Delivering a web site that provides uniform access to an array of widely different sources
  • Hosting and development of the search engine, Summa, powering said website
  • Hosting Summa-powered search engines for public libraries

I could write many a blog post about the magnitude of these tasks, but I shall leave it at this. But trust me, it takes quite a big more than someone who took a weekend course in PHP and another guy who happens to know that SQL is not an auction site :-)

Unfortunately for me I just missed out on Code4Lib conference this year – I am pretty envious of Toke, Mads, Jørn, and Michael who are going there this year – I am there in the spirit with you guys!

The winds of change were gently filling my footsteps with snow flakes - walking to my car from the State and University Library for the last time

The winds of change were gently filling my footsteps with snow flakes - walking to my car from the State and University Library for the last time

Bad thinking

Sunday, August 9th, 2009

It is now 11:09, and I’ve already spent a disproportionate amount of time today wondering how a modern GUI would look if it was designed for Sponge Bob Square Pants…

Please help. I need to think about something else!

On Algorithms and Children

Monday, January 5th, 2009

I hugely enjoy watching our children as they play trying to understand their mind a bit better. One thing that is absolutely certain is that small children do not think in any way as teenagers or grown-ups. They have a unique way of solving problems and analyzing situations that is just beyond parent comprehension. I have taken a stab at it nonetheless.

Taking my three year old daughter, Liv, my first observation is that she thinks very much in patterns. One example of this came today as she was drawing a bit. It was immediately obvious to me that she was following a very strict algorithm. I shall present it in full.

1. Draw a line. For a general three year old this will look something like:

2. Continue the line until you accidentally (or intentionally?) create a loop. If you don’t create a loop go back to 1.

3. Start filling the loop (making it to some measure “opaque”) by drawing small loops inside it. These small loops will at times spill outside the loop they are supposed to fill. In these cases you must also fill the new loop.

4. End or go to 1.

The end result of the above example could be:

Real World Examples

Liv drew the following today. I can’t help to find some fractal beauty behind it… Or maybe I am bit biased ;-)
Child Drawing, Liv, 1/2

When Liv left the drawing her little brother Lauge was eager to “help” her finish the details… A true Connaisseur d’Art may notice the subtle change in brush handling. Lauge is 1½ years old.
Child Drawing (Liv) 2/2

This concludes my thesis on algorithms and children. Thanks for reading.

Javascript meet Gnome, Gnome meet Javascript

Thursday, November 13th, 2008

Alt. title: The Very Long Blog Post About Gnome and Javascript that Will Surely Put You to Sleep

I shall not hide the fact that I am pretty excited about the “Javascript enabled Gnome”-idea. It has the potential for greatness if executed with care and consideration and the potential for boring irrelevance if not given proper thought. In this post I will try and give you my vision of greatness.

If you have nothing else to do, sit tight for a long read.

The Old New Application Model

This has more ore less been explained before, especially if you read the comments on Alex’ post titled “Embeddable Languages, an Implementation”, but I will include my own short version of it for completeness.

The development model behind the whole Javascript-movement is “Core in native code and the rest in an embeddable language”.  The “Core in Native Code” would be a core written in C, C++, Vala, or some other language compiling to native code. An “embeddable language” has the following traits in my mind:

  • Comes with very slim or no platform library at all
  • One can programmatically inject objects or modules into it from the embedding environment
  • It is completely sandboxable
  • The VM or interpreter is very light

These points makes it clear that Python, Java, and Mono are not “embeddable” in my book. The non-existing platform of the embeddable language is in fact a boon in our case because we already have a platform. Namely the collection of GObject based libraries in Gnome providing GObject-Introspection capabilities. This way different platform’s, I/O, networking, configuration and such don’t get mixed up, plus you automagically respect stuff like the Gnome proxy settings and such.

Also I would like to highlight that this does not suddenly make Python, Java, or Mono bad ways to write your applications. They are, and will continue to be, very good platforms, but they do not lend them selves that well to the Native Core + Embeddable Language application architecture.

The VM and the Language

We are fortunate enough to have at least three alternatives for choices of Javascript engine (henceforth JSE), SquirrelFish (WebKit), Trace/SpiderMonkey (Mozilla), and V8 (Chrome). Real VM-junkies could probably add a few more engines to that list. We already have GObject-Introspection-powered bindings for the WebKit and Firefox engines, respectively Seed and Gjs.

My (arguably not very thorough) review of the two Javascript bridges tells me that both are very strongly tied to their JSE-of-choice. While this definitely makes sense at the lower level I don’t think Gnome should tie itself to one single JSE. With all the massive work being poured into developing über fast JSEs these days I just think that it would be a very, very, bad call (or at the very least gambling with our performance).

Not having a blessed Javascript engine brings in host of problems the web developers among us probably know a lot more about than me. Reading Wikipedia’s article on ECMAScript should give you an idea of where I am going… Basically a portability problem that might be even trickier than porting good olde C code between different compilers and libc implementations. However I am confident that we can solve much of this by writing good coding-guidelines and assuring that the underlying Gnome technologies does not push developers in the wrong directions.

Writing a generic JSE bridge for Gnome would require that one carefully analyse our needs and intentions and write the interfaces for that. Any engine which API could not provide the needed functionality would not be eligible as backend. We can not accept the lowest common denominator just to make the developers of the RodentApe JSE happy.

The minimal requirements from a JSE would be the four points listed above for embeddable languages and add to that:

  • Can run several parallel “sessions” also called “contexts” in the same engine instance
  • Maybe: Security model that allows certain contexts to read and write to each other

Inheritance and Boiler Plate Code

It is important to realize that Javascript does not have the concepts of classes and inheritance. This means that you can not do sub-classing like you would in Java for example:

public class Base {
    private int i;
 
    public Foo (int i) {
        this.i = i;
    }
 
    public void frobate () {
        System.out.println("You have been frobated!");
    }
}
 
public class Sub extends Base {
    public Sub () {
        super(27);
    }
 
    public void newMethod () {
        System.out.println ("This was the new method");
    }
}

Javascript is a prototype based language this means that it is not based on classes and inheritance, but on “prototypes”. The way Gjs suggests one gets around this is like:

const Lang = imports.lang;
 
function Base(foo) {
  this._init(foo);
}
 
Base.prototype = {
  _init : function(foo) {
    this._foo = foo;
  },
  frobate : function() {
  }
};
 
function Sub(foo, bar) {
  this._init(foo, bar);
}
 
// copy each method in Base.prototype to the new Sub.prototype
Lang.copyProperties(Base.prototype, Sub.prototype);
 
// replace the _init property in Sub.prototype
Sub.prototype._init = function(foo, bar) {
  // here is an example of how to "chain up"
  Base.prototype._init.call(this, foo);
  this._bar = bar;
}
 
// add a newMethod property in Sub.prototype
Sub.prototype.newMethod = function() {
}

If this makes you think of the standard GObject boiler plate in C code you are not completely wrong. When I first realized this I was totally flipping “No way we are going with another boiler-plate heavy language”. Likely you are too if this is your first confrontation with this fact.

However, after letting my emotions settle for a few days I became a little more open to the idea. While a more pure sub-classing scheme could probably be implemented with some ninja-hackery I am not sure that would be a good idea. The point is that we don’t want to end up with something that is basically a Javascript dialect. Outsiders should have a fair chance of applying their regular Javascript knowdledge and possibly even port some existing code to Gnome. The point of keeping the Javascript in Gnome close to that of “the Wild” will be further signified below.

In fact it can be seen as a plus that the prototype based approach is similar to the GObject implementation. Namely that the mapping can be quite close. If you switch often between native GObjects and, fx., Java, you will probably (like me) miss some of the really powerful aspects of GObjects that are not found in standard Java classes. This can be more naturally mapped to Javascript.

Integration. Deep Integration

If Javascript ends up as “just another language binding” it will quickly become irrelevant. There are simply languages better suited for that. It needs to run inside the guts of our apps and everywhere across the desktop.

I guess that Firefox+XUL is really my role model here. Consider Firefox extensions (or is it called pluxtensions or strap-ins these days?) like GreaseMonkey and Firebug. No I don’t mean “consider” – you have to experience them. Taking Firebug; it really transforms Firefox from a cool web browser into an über cool, full featured, website debugger. You have to fiddle about with it to fully realize what I am talking about.

What I dream about in the pitch black nights of Denmark is this level of integration across the Gnome desktop, from the desktop as a whole to the nitty gritty details of the applications. Firefox has proven that it is not impossible and recent developments in GObject-Introspection, DBus, GtkBuilder, and the desktop wide scene graph of Gnome Shell, all hints to me a brighter future (don’t hold your breath though!).

Absolute Theming

Something that routinely bring me down is the state of Gnome application theming (I am not talking about Gtk+ themes, but application theming). From my early Linux days I remember that my shiniest gem was the KJofol skins for XMMS. They litterally transformed the entire UI of XMMS to something completely different. It looked bloody awesome and turned a lot of heads of Windows users at the time.

I am not saying that each and every app should look totally unique (we have fought a lot for desktop unity!), but just that we should still provide that expressive power to entrepreneuring talents. We are very far from that right now. But it can change…

The Native Core + Embeddable Language design fits the bill perfectly in fact. If the UI and layout code is (entirely or mostly) written in Javascript and the core/model is imported into the scripting environment the game of “theming” will change completely. Either one can utilize a DOM-like access to a scene graph, which could be the role of a plugin, or one could completely rewrite the UI much easier than one can today – some progressive distributions might choose to do that.

A side bonus of this application architecture is that it will more or less force you to separate model and view in your application. Something Gnome sadly has not been very good at.

New Developers?

One argument that has been repeated in contexts such as this longish blog post is that Javascript also brings a horde of new developers to the table. I don’t think this will automatically become true unless we take the utmost care.

Firstly when you are thinking about a “Javascript expert” what do you think of first? I bet you think about a savvy young web-hacker who can integrate HTML, Javascript/DOM-scripting, and CSS, in mind blowing web-apps that’ll work on all browsers down to IE5. I know I do. If we want to pull these guys in we have to make the barrier to entry very small. Javascript alone wont cut it. Something like DOM-scripting and CSS should be waiting for them.

Next we also want to make it very tempting to jump on board. The ultimate power of adding a new sub-menu to Nautilus is simply not cool enough. This is why my sections about Deep Integration and Ultimate Theming are doubly important.

Thanks!

Wow, you just made it through my longest blog post ever!

Three Simple Questions

Friday, June 6th, 2008

There are three simple questions that one should always ask one self when writing emails. Especially when writing mails to (public) mailing lists. Most importantly:

Would I say this to a person face to face?

And when writing to public mailing lists or a group of people:

Would I say this to a stranger?

Would I say this in public?

If the answer is no to any one of the questions, then don’t write that mail, or at the very least change it so that you can answer yes on all questions above.

These points does (obviously) not apply to blog comments. You are supposed to be loathful and derogatory in those. Feel free to fill the comments with obnoxious ranting :-)

Meme

Friday, April 11th, 2008
mikkel@delight:~$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
81 cd
80 bzr
29 ls
27 test/test-session
27 make
25 gcc
24 ./timeout-test-1
21 svn
20 ../xesam-tools/demo/rdfs2moinmoin
19 sudo

Infuriated

Tuesday, April 1st, 2008

Important: This post an April’s fool joke. I am noting it here because a lot of people have got upset about it. See my following post for related information.

original post starts here

Apple, the scum of the earth, what the fuck are you up to?

Minutes ago I was contacted by by some Melissa Sumthing, from Apple, claiming patent coverage one some parts of the Xesam spec. I was arguing that it was merely a spec, but she did not react to that. I was not really prepared to counter the lawyer-lingo so she thwarted me quite bad. Anyways I will take down xesam.org until further notice.

This makes me want to ask 2½ questions.

  1. How fast can we (L)GPL3 the entire Gnome stack (and any other GPL2 software)? Will this make any difference? (this is the ½ question)
  2. What does this do to the Webkit involvement in the FOSS world?

I am pondering all sorts of nasty retributions I would want to take on Apple, but I think I better take a deep breath before I take any action. Infuriated.

Update: I was advised to not take down xesam.org because that could imply that I was in agreement with the accusations.

end of original post

Platform, platform, platform (and integration!)

Thursday, March 13th, 2008

WARNING: Here follows a rant from a person without deep insight into the whole history of Gnome 2.0, but nonetheless feels qualified to give some constructive criticism.

Did anyone notice the 3 platforms in the title? That is no coincidence, because I am going to talk about platforms and my vision for Gnome 3.0.

It will serve you well to read Imendios vision of Gtk 3.0 before you read on.

Today

Desktop and Platform?

Currently Gnome is split in two parts, Platform and Desktop. If you want the formal definitions follow the links. Here are my version of the definitions:

  • Platform: Rock stable functionality. API and ABI guarantes. If anything here breaks you get to spank us and call us animal names
  • Desktop: If you have a dependency you don’t really know what to do about (and don’t like to #ifdef al lot) then lobby bit to convince people to put it here. These libraries should strive to remain API stable, but no guarantees given.

So the platform module sounds promising – how do you feel about the desktop module? Not too keen? Well some of the libs in desktop have individual API promises, but you get to figure that out for yourself. This project structure makes it very hard to get into platform (which is sane in this situation of course) and a lot easier to get into desktop.

Then you start skimming the list of platform modules (they do not appear in the listed order):

  • glib – check
  • gio – check
  • gvfs – check

Very sane so far

  • gtk+ – ofcourse, check
  • 4 libs for dealing with Bonobo/Orbit – wtf?
  • libart_lgpl – wtf? Don’t we have Cairo these days? Supposedly only used by the canvas widget.
  • 4 seemingly Gnome-utility libs (libglade, libgnome, libgnomeui, libgnome-canvas) – wtf?

I must be frank an say that as an outsider (in the sense that I have not been part of the decision process) the Gnome stack looks a bit like a mess. Putting it bluntly, only GLib (and its modules) and Gtk really seem attractive. Gnome does not really feel like a “platform”, it feels like a collection of libs. There I said it. Sorry.

My Vision

In short: More “plaform”, less “collection of libs”. Read on.

API and ABI Stability

As also proposed by Imendio (although mainly about Gtk+, where I am talking about the Gnome stacck) libs should not expose struct fields or other variables. Everything goes through getter and setter methods. This should make it a lot easier to maintain both API and ABI stability.

Release Schedule

6 months for minor versions. 3 years for major versions. Why force a major version bump every three years? This is highly dependent on the Desktop, Platform, Core section below which you should read before flaming me. Other benefits of a forced 3 year major release cycle:

  1. Satisfy the feelings that the types of users and developers who want Gnome 3.0 now have. Note that this has nothing to do with the technical aspects – feelings are emphasized. If major releases make people happy I say we make them happy
  2. Selling point for distros. “Our brand spanking new version of FoobarLinux comes with the shiny new Gnome 2.22.2.4.5.1.4 as opposed to the the former release who shipped 2.22.2.4.5.1.3″, or sed that with s/2.22.2.4.5.1.4/4.0 and do the math on the total revenue
  3. Keep things moving. Give developers a window of opportunity to bring new technology into the stack. This is possible today, but it is more inspiring to push for a major release

The underlying idea here is to be more loose around the major releases because of human emotions not technical issues. We should not underestimate how important motivation is.

Desktop, Platform, Core

  • Core: As platform today. Very hard to get in here, but with less cruft. Rock stable API adn ABI. Both are stable between major releases, this is more easy to maintain because of the new strategy noted under API and ABI Stability above. The idea is that other platforms such as XFCE or mobile platforms should also be able to depend on Gnome Core.
  • Platform: API stable between major releases, not ABI stable. ABI stability is only per major release number. Proprietary applications depending on Platform will have to distribute binaries for each major release.
  • Desktop: API and ABI stable per micro release (X.Y.*) in addition Gnome promises that the functionality in here is persistent for the whole major release cycle. Stuff might change API or even be moved to another lib, but you will still have a way to achieve the same effect without much hazzle.

Specifically for Core and Platform there is a “No Technology Leaking” policy. This means that we are not allowed to expose stuff from underlying libs such as X. Also for Platform and Core it is strictly verboten to stick application/lib-specific dependencies in here (libart, libeel). With Core and Platform you should be able to write just about any application. Desktop would contain the sugar to integrate with the official Gnome apps, and more specialized libs that a not of broad usage.

Namespacing – Especially for Core and Platform, but also to some extend for Desktop, we should be more aggressive about namespacing things under a g*-namespace. This gives a more coherent feeling. See for example libart, libbonobo, liborbit, libebook, et al. I realize that we cannot shovel everything into the g*-namespace, but can we just try harder?

Today Desktop contains cool stuff like GStreamer. Since GStreamer is not under the control of Gnome we can not really put it into Platform even though it might be cool to have there (if you don’t like the GStreamer example pick any other cool lib from the current Desktop module). To get such cool technologies into Platform or Core Gnome could be more aggresive with API indemnifying wrapper libs. While I am not sure I am all for what KDE has done with Phonon, a less aggressive solution could be fine to me. For example just creating a thin wrapper flexible enough to absorb underlying API flux, but not fat enough to flex out backends and other funkyness.

Specification, Abstraction, and Implementation

I am very exited about the “recent” trend of writing FDO specs and then implementing these (recent – like over the past years). I think we could a gain a lot from pulling more in that direction. Take for example the case of panel applets. If there where a clean specification for the construction and interactions with these then other platforms would have the opportunity to embed Gnome applets as well, without pulling in the whole stack. Since we are not allowed to leak underlying technologies we can not let the applet spec rely on XEmbed or X at all for that matter. Now who said GtkBuildable/DBus with some magic introspection glue? This could mean that Gnome applets could eventually run under KDE, XFCE or OS/X or WIndows.

Not all specs has to go through the FDO machinery. Gnome specific specs are also fine as long as they are stable like our APIs and respect our layering.

As also hinted in the paragraph about “API indemnifying wrapper libs, abstracting out some of our dependencies could bring us a lot of flexibility and possibly a host of new developers. With the help of an officially adopted IDL writing thin abstraction libs could be made quite easy.

Example

Just to make it clear about the proposed trinity of Gnome modules here’s a quick rundown of how it could look like:

  • Core: Glib (and modules), Gtk+, Some dbus stuff, a networking lib, XML. Basic accessibility
  • Platform: Lib for desktop search, and metadata management. GConf/DConf, libwnck, libxklavier, libgtop, gtksourceview, gstreamer, keyring etc. More advanced accesibility
  • Desktop: Lib to remote control Nautilus and other high profile apps, specialized (for audio/video, or images, etc) metadata handling libs (exempi for instance), panel integration, libart, librsvg,

Thanks for following me this far. Let the public humiliation commence (remember I am allowed to dream :-D ).

Update: Let me underline that I think we achieve a lot of this by using the codebase we have already. We need some extra spice (and IDL would come in handy) and then we’d probably need to break some API (not that much really) and remove a lot of deprecated modules. A lot of work, but not ridiculously much. Are we a team?