Mutant World

Saturday, May 14, 2011

Natty Narwhal's Unity, final take

I have previously blogged on Ubuntu's Natty Narwhal Unity shortcomings, and added some additional thoughts on my own configuration.

With a non-hiding Unity launcher that works as an old-style launcher and as a windows list, what I really missed were the applets.

It turns out that there are many efforts to replace those applets with "indicators", for example see this link.

So I installed the weather indicator, the system load indicator and this allowed me to get back to a decent configuration that I find efficient enough for my daily work.

Considering that Ubuntu will drop the "classic" mode for 11.10, I felt it was better to get used to Unity as soon as possible.

I am confident the application indicators will improve over time, so eventually - hopefully - Unity will be as good as the classic mode.

Thursday, May 05, 2011

Natty Narwhal's Unity, take two

I have previously blogged on Natty Narwhal's Unity shortcomings, but I decided to give it few more days, and I here are my further comments.

I configured the launcher with 32 pixels icons and disabled auto-hiding.
This basically brought me back an old-style launcher and a windows list that is always visible, allowing to glance at it for visual information regarding running applications.

Unity's launcher seems to be designed to play the role of both an application launcher (via icon clicking) and of a windows list (via small arrows and additional icons). I still think that the two concepts needs to be separated, but I am starting to get used to it.

It's still not like the classic mode; for example, there is one icon only in the launcher for all the Terminal instances, which gives less information on what is the Terminal window you are currently working on.

I discovered that middle-clicking on a launcher icon creates a new instance of the application, so this issue always had a solution.

Disabling auto-hiding made usage of the browser's application tabs easier, since now the launcher does not pop up overlapping the browser's application tabs when you hover with the mouse in the top left corner.

I still really miss the applets, and I hope that Unity will be improved to allow an additional panel (at the bottom, say) to make room for the applets.
This new panel could be missing by default (but could be added if one wants to).
And I am really missing the old date/time/locations applet: the new one is just too bare bones for my taste.

Finally, I noticed that Unity is way slower to start, but that's once in a day pause for me, so it's tolerable.

Friday, April 29, 2011

Natty Narwhal's Unity is not for me yet

I have upgraded to Natty and I am trying out Unity, but I am afraid I am not the right user for it.

Unity does not seem to be designed for power users like me (which is fine), but unfortunately it is not yet flexible enough to support both casual users and power users like me.

The new user interface is clean and polished, but did not impress me much, visually (not after wobbly windows and the desktop cubes). It's a couple of panels of which one autohides.
And a big step back on the user interface of available applets (see below).

What I miss most is the lack of applets support, as I often glance at the CPU, network and disk I/O indicators; and the lack of the windows list, as I often glance there to see what I am running.

For example, how do I know if I am running XChat so that colleagues can contact me ?
Previously, a glance to the windows list was enough; now I have to alt+tab or, if I have a maximized window (which is often the case), make the launcher visible (move mouse there, wait). Both are way slower than a glance. You need to operate instead of just glancing.

As another example, I often run a "server" terminal and a "client" terminal, and I know that the server comes before the client in the windows list. A glance at the windows list is again enough to tell which terminal is what. Not possible with Unity.

Compiz Config Settings Manager allows to fine tune the configuration of various effects, but sometimes it's just too sparse.
For example, alt+tab has a popup delay of 200 ms (it's a lot for a me... I started thinking my computer had become slower with the upgrade to Natty). Where is that settings ? In "Effects" ? In "Static Application Switcher" ? Somewhere else ?
You need to navigate CCSM and find it, and decrypt the various configuration options (for example, can anyone tell me what is the "timestep" option of the switcher ?)

Firefox allows you to create "application tabs" that have a small icon to represent a page. If you want to go to one of those tabs, you need to be precise in clicking it (because it's small).
If you have Firefox maximized, the first application tab (GMail in my case) is dangerously close to both Unity's home button and Unity's launcher; if you are few pixel off and hover on the home button, the launcher starts to reveal, but by doing so it will partially cover Firefox first application tab; few pixels off on the left border, and the launcher appears, covering again Firefox first application tab.

Multi instance applications like Gnome's Terminal cannot be easily instantiated from Unity's launcher: you can do that easily for the first instance, but trying to open a second Terminal in the same way brings you to the first Terminal. I think the principle of least surprise is violated here (or to say it less politely, WTF ?!).
Double clicking on the icon reveals all instances, and right clicking shows a menu that does not have an entry that allows to create a new instance.

And yes, I do know that I can configure Unity and Compiz, I also know that Terminal has a special Unity keyboard accelerator, but the accelerator does not work if you have a maximized application focused (it will be interpreted by the application, not by Unity).
It's just that Unity is more complicated than the classic mode, and less customizable.

Most of the applets for the Unity panel are a step back, especially the Time/Location applet (no icons, no solar light projection on Earth), and the Configure Display applet. The latter does not ask you anymore if you want to use the proprietary driver tool instead... now how do I find the proprietary tool ?
Exploring Unity's launcher is no help (in which category could they have put it ?) until you type "nvidia" in Unity's dash (and you start thinking "thank god it had 'nvidia' in the name, otherwise I'd be seriously screwed in finding it").
And I am the guy that knows its video card is an NVidia one, otherwise, well...

The visual cue for notifications is a (really) small triangle in the top left corner.
You can't tell if it was a Skype notification, XChat notification or something else, it's one cue for all, and you need to click on it to figure out which notifications.
Before, the windows list gave different cues for different application, and a glance was enough to figure out which notifications.

All in all, I am disappointed even if I set my expectations really low.
I will give Unity a bit more time, but I am resisting the urge to switch back to the classic mode.

I really hope that the classic mode will not be removed, or at least I hope that Unity will improve so much that will be more friendly and configurable for power users as well (or for me at least - but I am guessing I am not the only one).

I personally care about number of eye glances, number of mouse clicks and number of switches between keyboard and mouse of my hand. I would like all of them to be reduced at minimum and right now Unity forces me to a lot more effort to get the same things done, so it's a (big) step back.

Tuesday, August 04, 2009

Jetty Support for Cross-Domain XMLHttpRequests

Remember the same origin policy that restricts most of our JavaScript applications ?

Seems that we can finally get rid of it, thanks to a new W3C specification already implemented by Firefox 3.5 and, on server side, by the Jetty Servlet Container.

I blogged about all the details here.

Oh, if you're using Ubuntu Jaunty, you can install Firefox 3.5 via apt://firefox-3.5. It is named "Shiretoko" (its codename), but it's exactly Firefox 3.5.

Time to move on !

Labels: , , , ,

Wednesday, July 29, 2009

JavaScript Cometd

Lately I have been working with JavaScript, in particular I have written a JavaScript library that implements the Bayeux specification for the Cometd project.

I have to say that I really like JavaScript, the language.

Don't be fooled by "Oh, it's only for modifying CSS in web pages" because it's really a nice language, although it's misunderstood.

You can write nice applications in JavaScript and today JavaScript toolkits (such as Dojo or jQuery) helps you to figure out browser differences and make a wonderful job at reducing the code that you have to write, allowing you to concentrate on the business and not on the technical details.

I have blogged about the Cometd library I have written here.

Enjoy !

Labels: ,

Tuesday, January 13, 2009

Creative Webcam Live! on Ubuntu Intrepid Ibex

I received the Creative Webcam Live! as a gift quite some time ago, but never had the time to use it or install it properly.
My good ol' Thinkpad T43p was maybe bleeding edge in 2005, but not as far as having already an incorporated webcam :)

Under Ubuntu Intrepid, this webcam does not work out of the box, at least for me, and I have a fresh (re)install of Intrepid.
This camera appears using lsusb as:

Bus 003 Device 008: ID 041e:4036 Creative Technology, Ltd Webcam Live!/Live! Pro

The solution is quite easy though: you need to set this variable before launching the program that uses the webcam:

export LD_PRELOAD=/usr/lib/libv4l/

I tested this with camorama and skype, and in both cases it works just fine.
For skype, I created a wrapper script that first set the variable as above and then invokes /usr/bin/skype and modified the menu entry to point to my wrapper script.


Monday, December 29, 2008

Visibility in JavaScript

The topic of visibility of members and functions in JavaScript has been figured out already, and there are good resources, among which one of the most important is Douglas Crockford's Private Members in JavaScript.

Here I just recap my experience for my own (and for anyone interested) future reference.

I am pretty paranoid in making all members and methods with the least possible visibility in my Java code. Before opening up a method as protected or public, one should always remind that most of the times, once it's opened up, you cannot close it because other code uses it.

JavaScript can have private members and functions, and I mostly use two idioms for this: the constructor function and the the object initializer.

The constructor function

I use the constructor function technique when I want to create few objects that behave the same (in Java you would say "few objects that belong to the same class", but JavaScript does not have classes).

var MyNS = {}; // An optional namespace
MyNS.Service = function(offset)
var _privateMember = offset;

function _privateFunction(value)
return _privateMember + value;

this.myFunction = function(value)
_privateMember = _privateFunction(value);
return _privateMember;

The common convention is that function names beginning with an upper case letter are constructor functions, in this case Service.

From the example above, private members are defined within the constructor function using the keyword var, private functions are just nested functions within the constructor function, and publicly accessible functions are defined with the this.<functionName> idiom.
The function myFunction in the example above is a privileged function, but for the sake of visibility it can be classified as public because anyone can invoke it.
From the example above, you see that myFunction can refer to private members and functions.

However, referring to publicly accessible functions from private functions is not possible:

// A constructor function without namespace; does not work
function Service2()
var _open;

function _clean()
if (_open) close(); // Does not work: ReferenceError

this.close = function()

It is not possible to call privileged functions from private functions. In my experience this is not a big problem, as it is possible to refactor function close() into a private function _close() and call the private version from both _clean() and close().

With a constructor function it is possible to create several objects that behave the same. In the example above you can create several service objects using the following syntax:

var s1 = new MyNS.Service(1);
var result1 = s1.myFunction(5); // returns 6

var s2 = new MyNS.Service(2);
var result2 = s2.myFunction(0); // returns 2

As you would expect, object s1 and s2 have different internal state and can be used independently.

The object initializer

I use the object initializer technique when I want to create a singleton object.
My preferred way of using the object initializer technique is via a function with immediate invocation, which allows to have private members and functions:

MyNS.EventHandler = function()
var _queue = [];

function _privateFunction(event)

return {
handle: function(event)
get size()
return _queue.length;

Note the parenthesis at the end of the function definition, which perform the immediate invocation of the function.

Similarly to the constructor function technique, it is possible to define private members and functions, but the object initializer technique also allows (for non-crappy JavaScript interpreters) to use the getter and setter notation.
In the example above I used the getter notation to define a read-only property called size, which can be accessed like this:

var s = MyNS.EventHandler.size;

Using the getter notation is much nicer than having a getter function, and much better than having a public member (which would be not only readable but also writable).


Both solutions outlined above have the problem that for each object created in those ways, the function definitions are also duplicated: each object will have its own copy of the functions, and this will result in more memory occupation. That's why I suggest the constructor function technique when you create few objects and the object initializer technique for singletons.

At first, I thought that there must have been a way to have private visibility for member and functions, but only one copy of the function definitions, very much like Java does: each Java object has its own copy of the members, but they all share the methods definitions.

Unfortunately I could not figure out how to do it, not even reading JavaScript library code such as Dojo or jQuery.

However, there is a different technique that it is possible to use to share the functions definitions, which I will call here "public members and prototype".

Public members and prototype

When you have to create lots of objects with members and functions, the best technique is to define the functions in the prototype, so that they will be shared by all objects, and have public members holding the state.
You have to give up on restricted visibility (members must be public) to save memory (only one copy of the functions is shared by all objects), because functions defined in the prototype can only (to my knowledge) refer to public members.

MyNS.Event = function(source)
this._source = source;
MyNS.Event.prototype = function()
var _privateStatic;

function _privateFunction()

return {
consume: function()
this._consumed = true;
get source()
return this._source;

In this example, MyNS.Event is a constructor function that allows to create events via:

var source = window;
var event1 = new MyNS.Event(source);

The constructor function defines a public member called _source, which can be later referred from functions.
Also functions in the prototype can define public members (like _consumed in function consume()).

All function definitions are defined in the prototype. Note how the prototype object is returned via immediate function invocation, which again allows to have private functions and members as in previous techniques.

The interesting part comes when you define private members in the prototype, like _privateStatic.
These members can only be modified by functions defined in the prototype, which are shared by all objects. The result is that modifications made by one object to _privateStatic (via shared prototype functions) are reflected by all other objects created with the same constructor function. This behavior is the same behavior of static members in Java.

Instead, public members modified by functions defined in the prototype are attached to the object (not to the prototype), so that each different object has its own copy of the members, and therefore they can be modified independently:
function A(value)
this._field = value;
A.prototype = function()
var _staticField;
return {
staticGetter: function()
return _staticField;
staticSetter: function(value)
_staticField = value;
instanceGetter: function()
return this._field;

var a1 = new A(1);
var a2 = new A(2);
a1.instanceGetter(); // returns 1
a1._field; // public field, returns 1
a1._field = 3;
a1.instanceGetter(); // returns 3
a2.instanceGetter(); // returns 2
a1.staticGetter(); // returns 'foo'

I'd be interested in any solution that will allow private members with prototype-shared functions, if this is possible in JavaScript.