Posts Tagged ‘gnome’

Hamster is one of my favorite apps in Linux. I use it so much that I had previously written a post on it at Time Tracking in Linux using Hamster. One of the problems, I faced when I installed Natty was that it does away with the notification area (or systray). This means that the hamster applet will not be loaded in the panel automatically.

In the Launchpad, there exists a bug that discusses ways to add indicator support to Hamster. The author of Hamster has indicated that ,for now, he is not going to write a version for GNOME 3.0 (using GNOME Shell). I took a look at the code and it seems interesting – although I am not fully familiar with hamster graphics methods. If Unity support is not built into hamster in the near future, I will take a stab at it. In this article, I discuss some workarounds to still use Hamster in Ubuntu Unity or GNOME Shell  . They range from the easiest to hardest.

Method 1

If you are using Ubuntu Unity, the best alternative is to use the hamster version developed by Alberto Milone. The description of his work is this page – Appindicator for Hamster . Basically, he created a child class of HamsterApplet which has appindicator support. Pretty neat ! I browsed through the code and it seems straightforward. Hopefully, it will go into the upstream.

The instructions to use it are given in the linked page. Basically, you download the python code from hamster-appindicator’s github page. If you do not know how to use git , then just download the raw Python file . Put it in some folder and invoke it as "python hamster-indicator.py &". You can also add it to your Ubuntu startup applications !

Method 2

Since hamster applet is nothing but a Python app, you can technically invoke it as a standalone application instead of an applet. Most of the time, the utility must be in your path. You can invoke it as "hamster-time-tracker &" (or "python /usr/bin/hamster-time-tracker &") and by default, it will open a new stand alone window for the tracker. One thing to notice is that, this view does not have the "Add earlier activity" button. So this is only useful , if you want to add tasks starting now. Or you can muck around with Hamster’s use of negative time (-x a@b,c means I have been doing activity a of category b with description c for the last x minutes).

If you want to add earlier activities, invoke hamster as ,

    hamster-time-tracker toggle

  There are other options also. The entire list is overview|statistics|edit|preferences|about|toggle . The overview mode opens the "Overview" window that allows you to browse your activities for this week/month etc. The statistics mode shows a chart of your activities. The edit mode opens a new window that usually shows up when you click on "Add new activity". It allows you to enter activity,category, description, tags starting at arbitrary time.

The only catch is that it does not always visible and hence you might forget that it even exists ! If you are not as absent minded, then this is the best way to go (especially in GNOME 3.0 or GNOME Shell).

Method 3

Use this method, if none of the above works. This is only for masochistic hardcore geeks. The basic idea is to use the hamster-service that runs in the background and use the hamster’s command line utility. Just invoking the command line tool "hamster-cli" will give you a list of options. They are :

(1) list-activities : You can invoke this option to list all the activities and their respective categories. The format of output is activity@category . This is useful if you want to add a category using command line. The invocation is
    hamster-cli list-activities
(2) list-categories : This will show a list of all available categories. Usually this is superfluos as list-activities gives you the categories also.
(3) stop : This stops the task that is currently being tracked by hamster.
(4) list : This , by default(without arguments) , shows all the activities tracked for today. You can also give hh:mm-hh:mm option to display activities between specific time.

    hamster-cli list
    hamster-cli list 00:00-12:00

The first shows all of today’s tracked tasks while the second shows till 12 PM.

(5) start : The most important switch. This allows you to add a new activity – This can start now or at an earlier time. The format of entry is to give a activity with its category, optionally start time and description.

Currently, you cannot add new category or activity types using hamster-cli. You can only add/track a task using existing activity/category. If you want to add new activity/category use "hamster-time-tracker preferences" command to open Hamster’s preferences dialog which will allow you to do that .

    hamster-cli start "Blogging@Blogging"
    hamster-cli start "Blogging@Blogging,Hamster Post" 19:00-21:00
    hamster-cli start "Blogging@Blogging,Hamster Post" -00:40:00

The first invocation starts a new ongoing task of activity type Blogging and category type "Blogging" (after the @). The second invocation adds an earlier task of blogging between 7-9 PM. The third invocation starts a new task of blogging that started 40 minutes ago and still ongoing.

Hamster allows a more sophisticated time specification mechanism for start. I will put the details verbatim from the help of hamster-cli.

Time formats:
    * ‘YYYY-MM-DD hh:mm:ss’: Absolute time. Defaulting to 0 for the time
            values missing, and current day for date values.
            E.g. (considering 2010-03-09 16:30:20 as current date, time):
                2010-03 13:15:40 is 2010-03-09 13:15:40
                2010-03-09 13:15 is 2010-03-09 13:15:00
                2010-03-09 13    is 2010-03-09 00:13:00
                2010-02 13:15:40 is 2010-02-09 13:15:40
                13:20            is 2010-03-09 13:20:00
                20               is 2010-03-09 00:20:00
    * ‘-hh:mm:ss’: Relative time. From the current date and time. Defaulting
            to 0 for the time values missing, same as in absolute time.

To see other information, type "hamster-cli" without any arguments in the command line. It will show a helpful list of commands.

Method 4

One of the comments in the Launchpad asked for Hamster to behave like a docky helper. If thats your thing, follow the instructions at  this page . I have not personally tried it but hopefuly it will work.

Method 5

This is something I tried but did not work. Basically, I tried to add hamster to the whitelist of applications that are allowed to use notification area in Unity. You can find the details of how to enable any application to use systray at this askubuntu question.

I tried entering various incantations like hamster,Hamster,Time Tracker,hamster-time-tracker, hamster-tracker and so on. Somehow none of these worked. If anyone got it to work please let me know in the commands.


In conclusion, Hamster is one of the coolest apps in Linux and this post discusses some workaround for using it in Unity or GNOME 3.0 /GNOME Shell. Hopefully, indicator support will be built in the upstream itself soon. Have fun with Hamster !

Read Full Post »

In this post, I plan to talk about Ubuntu Unity. There has been hundreds of post on Unity . I will try to refrain from posting yet another Unity review. I assume that by choice or force, you are currently a Unity user. I plan to discuss how to make your life more productive by mastering it. So I will discuss various shortcuts, configurations and other cool stuff that I found in my 3 months(From Mar 2011) of active usage. Hence, this post will be slightly more technical. If you want an introductory post/review on Unity, check out the exceptional post by Ryan Paul here   .


Unity has been one of the most controversial products released recently and the reaction has been surprisingly polarized. Lot of people hate it and lot of people love it. Whatever be your position, it is a good idea to learn to use the Unity paradigm because this is the direction that most of Linux community is moving. For eg, GNOME Shell, which is another popular alternative for Unity , also has similar design vision. So, it is safe to say Unity is a harbinger of a potential UI revolution in Linux. Whether this will cause more users to come to Linux is yet another matter 🙂


Before we discuss about Unity, I think it is a good idea to give an orientation of various Unity components. This will help you when you read other posts or when you ask questions in some forums.

Unity :  Unity is nothing but a desktop “shell” to GNOME. GNOME Shell is yet another alternative. One of the key things to understand is that Unity was designed as lightweight shell as it was focused towards netbooks running Ubuntu. Understanding this will provide an appreciation of Unity’s design decisions. Since  it is targeted towards netbooks, it tries to conserve screen space as much as possible. Unity was ported to desktop in Natty. It is internally written as plugin for Compiz.

Ayatana : This is another name that you will come across. Ayatana can be considered as an umbrella project primarily focusing on UI and design stuff in Ubuntu. Some of the notable projects are Unity, Unity 2D,  MultiTouch, App indicators, Me-Menu and Notify OSD. See their launchpad page for more of the projects they run.

Unity-2D : Unity 2D can be considered as poor man’s Unity.  If your computer does not have the necessary hardware capabilities to run Unity, Unity-2D will act as the fallback. In Natty, the classic GNOME was provided as the fallback. Starting from Oneiric, Unity-2D will be the fallback. It is primarily written in QML and uses Metacity. Even Unity-2D replaces panel, launcher and other stuff.

Mutter , Clutter , Compiz and other stuff : Unity is primarily written as a plugin for Compiz window manager. The toolkit uses in Nux which is claimed to be faster than Clutter. Nux acts as an interface between Compiz and Unity. GNOME Shell uses Mutter (Metacity Clutter) as the window manager. Metacity is yet another window manager used in GNOME 2.2+ . Clutter is the toolkit. Both Nux and Clutter are opengl toolkits that provide convenient hardware based acceleration if available. This is the reason why both Unity and GNOME Shell uses a toolkit that has this support. For Unity 2D, the window manager is Metacity (even though Compiz can be used). If all of this confuses you , ignore it. Other than hard core geeks, nobody cares about these.

Wayland : This is a development that I am excited about. Wayland is primarily a display management system (also a protocol), just like X Window system. Instead of making some assumptions about Network and stuff, Wayland allows you to use native opengl to provide great graphics. The vision is quite fascinating and I hope it will turn out great.

Now that you know the overall big  picture, lets dive down to specific UI elements in Unity. The following text is based on my interpretation of Canonical’s design blog and this excellent AskUbuntu question  .

Ubuntu Button : This is the big button on the left top of the screen.

Launcher : This is the entire strip on the left that comes up when you hover over the left side of your screen. This will contain multiple types of icons. Icons that act as launcher icons for other applications, icons that show the currently running applications , lenses and workspace switcher.

Accordion : If you open lot of applications such that the launcher does not fit,  the icons are displayed in an accordion fashion – Basically, few of the icons are vertically stacked and if you hover your mouse over them it expands to show the icons that are present there.

Sigil : As said before, Launcher may contain some icons always – even if the application is not running. If the corresponding application is launched (or some other application), the icon in the launcher will contain a small white arrow called the sigil. It denotes that the application is currently running. The number of sigils denotes the number of instances of the same application.

Quicklist : Quicklists are another really cool idea in Unity. Although not as polished as Windows 7, it shows lot of promise. Quicklists are the common tasks that you do in an application that is accessible to you when you right click the application’s launcher item. Quicklists can be anything – For eg quicklist for a browser might be to open a new instance, open in incognito mode, go to specific site etc.  Alternatively, if you use Banshee/Rhythmbox, you can have all the music controls (Play/Pause/Next/Previous) in the right click.

Dash : The full screen black translucent overlay that appears when you press Super. Alternatively, you can click on the Ubuntu button. It contains a search option and also broadly classifies applications like Media, Internet etc.

Lenses : Lenses are one of the coolest ideas in Unity. Even though Dash allows you to search , its use is fairly limited to items in your computer. Lenses take the idea of the dash and extend it in such a way that it can search arbitrarily anything. You can kinda consider “Files and Folders” and “Applications” on the launcher as a special kind of lenses. They are currently called Places but their usage will be deprecated. There are lot of other cool lenses – For eg, one which searches sub-reddits , one that searches contacts , Amazon , Youtube etc. The API is also pretty awesome. I was able to code a lens to show the latest tweets of a user just by typing their name within couple of hours. If no one writes, I will write Lens tutorial sometime soon !

Panel : The strip that is at the top. The panel has been thoroughly given a facelift in Unity. It now performs lot of tasks. By default, it shows the title of the current active applications. When you hover your mouse over it , it shows the menu items of the applications. On the right hand side are the app indicators.

Global Menu : Also called as Application menu. When an application is active, this part of the panel will show the window controls  (Maximize/Minimize/Close) and the window title. If you hover over the panel or press Alt key, it changes to the menu of the application.

App Indicators : These are the icons on the right side for the panel.  By default it contains Sound, Network, Mail/Chat indicator, time , Me-Menu etc. You also add other indicators if you wish. To see the potential of these indicators, check out the sound indicator. It contains all the buttons to control playing and also allows you to select other playlists.

Overlay Scrollbar : Overlay scrollbar is one of the innovations in Unity designed to save space. In a typical application that needs scrolling, the scrollbars appear taking up valuable pixels. In Unity, the scroll bar appears as a thin strip. If you move your mouse over it, the classical scrollbar appears.

Keyboard Shortcuts for Accessing Unity Items

Exhaustively discussing all the features of Unity is beyond the scope of this blog post. If you are interested, see Ryan Paul’s article linked above. I will discuss the most important stuff and will intersperse mouse and keyboard based access. If you are a keyboard junkie, all of Unity’s keyboard shortcuts are here  .

Launcher : This can be activated by hovering over the left end of the screen. Alternatively, you can class keep pressing Super key for couple of seconds to make it visible. The initial delay is to prevent accidental invocation. If you are not comfortable with the default behavior, you can change it . See the section of unity configuration below. Since Unity removed the bottom panel that used to show active windows in the current workspace,  viewing the launcher is one way to see all the open applications.

Launcher Items : Once the launcher is visible , you can click on any launcher item to launch the application (if not already running) or bring it to the foreground. If you are a keyboard person, keep pressing the Super key. The launcher will appear with a character appearing on each of the icon. Pressing the character along with Super key will launch the application. For eg, Super+a starts the application places and Super+1 launches the application corresponding to the first icon in the launcher. Pressing Shift or using middle click will start a new instance.

Operations on Launcher Items : The default set of launcher items are not ideal and you many want to do some personalization. The simplest is reordering of icons. You can do it by either clicking on an icon and moving it up. Or you can click on it, pull it to the right and then place it at the right place.

If you want to remove a launcher item,you can drag the icon to the trash. Unfortunately, the obvious action of pulling the icon out of the launcher does not seem to remove the icon. If you have used any docks like docky or AWN , this might seem unintuitive.  If you want the icon to never appear in launcher, launch the application and right click on the icon and unselect ‘Keep in launcher’ option.

If you want to add a new application,the easiest way is to launch it by other means. Once the icon shows up in the launcher, right click it and select ‘Keep In Launcher’. Putting arbitrary application is a bit tricky. See the ‘Advanced’ section for details.

Lenses : Super+A opens the application places (lens) and Super+F opens the the Files and Folders lens. Super+T opens the trash.

Dash : Pressing Super and releasing it immediately brings the dash. If you use Alt+F2, it brings out Dash version of “Run” dialog.

App Indicators : Pressing F10 highlights the first app indicator menu which you can use keyboard navigation keys to select. To move to the other indicators press left or right arrow keys. For eg, pressing F10 for me opens the network indicator. Pressing right opens the volume indicator applet and so on. Of course, pressing Esc removes the focus from indicators.

Show Desktop : Pressing Super+D minimizes all the windows and shows the desktop. Pressing it again restores the windows.

Workspaces : If you press Super+W , it will create an Expose like effect showing all non minimized windows in all workspaces. If you want only for current workspace, type Shift+Alt+Up arrow. Moving a window to another workspace is not obvious as the bottom panel is removed. There are two ways : Press Super+S and it shows all the workspaces with the current window highlighted in current workspace. You can now use mouse to move window across the workspaces. If you want to move using keyboard, press Ctrl+Alt+Shift+ Arrow keys. You can may recognize that Ctrl+Alt+Arrow is the key combination to move across workspaces. Adding a shift, moves the window to the appropriate workspace.

Configuration and Personalization

One of the nicest things about is that it is highly configurable – Especially, if you do not mind getting your hands dirty with terminal stuff. In this section, I will discuss basic configuration of Unity and how to personalize it using quicklists and additional lenses.

To do the basic configuration, you would have to install “CompizConfig Settings Manager” (ccsm) from Synaptic. Once you have installed it press “Alt+F2” and enter “about:config” to access it. If you typed “ccsm” instead, search for Unity in the search box and get the “Ubuntu Unity Plugin” dialog.


My favorite settings are :
(1) Hide Launcher to “Dodge Windows”
(2) In Experimental tab, set “Backlight Mode” to “Backlight Toggles” . This will help you identify active and inactive launcher icons from their backlights.
(3) Launcher Icon size to 32 pixels.


Custom Launchers:
You might custom applications to your launcher. There are multiple ways to do that – The easiest is the following :
(1) Right click the desktop and select “Create Launcher”
(2) Set the launcher type – typically it is Application
(3) Enter the name of the launcher. This will be the name the Launcher icon will show if you hover over it or right click it.
(4) Enter the full command line path in Command field.
(5) Optionally enter a comment. You can also edit the icon by clicking on the icon’s icon 🙂
(6) Click ok and save the item. This will be saved in your desktop.
(7) Now drag this item on to the launcher.
(8) Voila ! The item is added to the launcher !


Custom QuickLists :
You can also create custom quicklists. The method is not very hard but involves editing configuration files manually.  The basic idea is as following :
(1) Find a similar .desktop file from /usr/share/applications/ and copy it to ~/.local/share/applications/ with the name as per your wish. Of course, you can keep it in any folder you wish but ~/.local/share/application is customary.
(2) If your .desktop file has a line like “OnlyShowIn=GNOME;”, change it “OnlyShowIn=GNOME;Unity;”
(3) At the end of the file , add the following line “X-Ayatana-Desktop-Shortcuts=shortcut1;shortcut2” . Replace shortcutx with your name of shortcuts. Each of them , except the last, must be separated by semicolon. It is better to have each shortcut name to be a single word.
(4) For each of the shortcut, add a section like this :

[shortcut1 Shortcut Group]
Exec=Command to run

(5) Things to note above are that the name of the shortcut at the beginning and in each section must match exactly.
(6) Go to this folder using Nautilus. If you want to see hidden files, press Ctrl+H. Or type “xdg-open ~/.local/share/applications/” in the command line. Now drag and drop the file you modified into Launcher.
(7) Remember, if you delete this desktop file, the launcher icon will also go !

One thing to realize is that to get access to these quicklists, the launcher icon need not always be in the Launcher. For eg, I want the quicklists for Banshee but I do not want Banshee’s icon cluttering up my space. If you are like me, make the change to the desktop file and put it in ~/.local/share/applications but do not drag and drop to Launcher. When you start the application, then Unity will automatically show the quicklist options. If the application is closed, the icon also goes away !

If you are too lazy to do all these, check out this link  for lot of awesome custom launchers and quick lists.


GNOME Applets :
Every Gnome user will have their own share of Gnome applets. Unfortunately, Gnome applets by themselves are not possible to be used directly in Unity. This is not just a Unity . The same holds for Gnome Shell too ! In Unity, they have to be adapted to use the indicator api to showup on the panel.

Systray Access :
You may use lot of applications that lands up in Systray. In Unity, you many notices that they are not shown at all. Most of the time , it does not really matter. But if you really wish to make the application show up, you need to add the application to a whitelist. The details are given in the following link  .

Lenses :
It is not very easy to create custom lenses without knowing programming. Some of the currently popular ones are given in the link  . I really like the Gwibber based lens. I am looking for a lens that uses tracker for better file search though.


This is a random collection of tips that I found useful. Some of them are discussed elsewhere in this post too !

(1) To launch a new instance of an application, middle click the launcher icon . Pressing Shift will also start a new instance.
(2) To move an application another workspace, make sure the application has the focus. Press Super+S and move the application to appropriate workspace. Alternative press Ctrl+Alt+Shift+ Arrow key to move it.
(3) If you like global menu bar and want Chrome to have it, enter “about:flags” in Chrome. Search and enable the “Experimental GNOME menu bar support” .
(4) To access the Unity settings manager, press Alt+F2 and type “about:config”. This directly gives the dialog to change Unity’s settings. To go to Compiz settings,  use “ccsm”. 
(5) If you mess up your Unity settings, try “unity –reset” .
(6) If you want to access special quicklist for an application but do not want the application taking up valuable space in Launcher when not active, there is a way to do that. Create the desktop file and put it in ~/.local/share/applications but do not drag and drop to Launcher. When you start the application, then Unity will automatically show the quicklist options. If the application is closed, the icon also goes away !
(6) If you were a hamster time tracking applet user and lost it in Unity, there is a hack that makes it work ! Check out this link for details http://albertomilone.com/wordpress/?p=502 . This works perfectly for my use !


There are lot of excellent links that helped me compile this list.
(1)  Ryal Paul’s in depth Unity review : http://arstechnica.com/open-source/reviews/2011/05/riding-the-narwhal-ars-reviews-unity-in-ubuntu-1104.ars .
(2) Power user’s guide to Unity : http://castrojo.tumblr.com/post/4795149014/the-power-users-guide-to-unity
(3) Unity Lens Architecture document : https://wiki.ubuntu.com/Unity/Lenses
(4) Unity place sample  : https://code.launchpad.net/~unity-team/unity-place-sample/unity-place-python

Read Full Post »

    I installed Natty Narwhal when the beta1 came few days ago. I wanted to write a blog post with the instructions to upgrade to Natty but kept postponing it due to Unity issues I was facing. Now that the system is working as I prefer, I thought I will put out a brief post on upgrading with a few tid-bits on using Unity. I am collecting some useful tips on Unity for the power users and will put out a post about it sometime soon.

    There has been lot of confusion about installing Natty. Most of the initial beta1 reviews were very critical with some calling it as the worst Ubuntu beta ever. I also had a horrible experience initially. During my initial install, Ubuntu Unity failed to work and the screen will have black patches wherever my mouse points. I tried lot of different configurations like installing Nvidia drivers or using Nouveau drivers and so on and nothing worked for almost a week. I was pretty disappointed. But after a week and few updates later, Unity started working like a charm. As of now , I do not have any issues in Natty so I can confidently advise people to upgrade it from Maverick.

To Upgrade or not to upgrade ?

    This is probably the first question you must decide – For me the answer is simple : If you are running some production server or anything sensitive , don’t install it. Just wait for two more weeks. The final version goes out on Apr 28th.  If it is your personal laptop, you are Linux geek and wanted to earn some karma, then what are you waiting for ? Start the upgrade ! Of course, there might be minor hitches and potential instability as it is still in beta – But if my experience is any guide, it is very stable now. The things you gain by installing outweighs the minor annoyances.

Upgrading to Natty from Maverick

    The conventional method that is specified in the Ubuntu website is to type the following in the terminal (or by pressing Alt+F2 and typing it in the Run dialog)

    update-manager -d

The other equivalent command is of course :

    update-manager –devel-release

Most of the time , I assume that this should do the job. Your update manager will open up, show that Natty (11.04) is available for download. All you need to do is click on "Upgrade" , sit back and relax !

For some reason, this upgrade took a huge amount of time. I had a reasonably fast internet but still the installation took almost 2 hours. Of course, your mileage will vary. The upgrade by itself was quite straightforward and no surprises.

What if you cannot see the upgrade option to Natty

1. Go to System -> Administration -> Software sources.
2. Click on the "Updates" tab and check "Pre-released updates".
3. Click on "Close" button. This will refresh the package list and most likely will open up the package manager that will show a huge list of packages to upgrade. Hopefully, it will also show "Natty Narwhal (11.04)" upgrade option.
4. Now close the update manager and open the Software sources again (same  as step 1). Now undo what you did in Step 2 – Un check the “Pre-released updates” option.
5. Click on "Close" button and the package list will be refreshed again. Now you should see the upgrade option to Natty saying : "New distribution release ‘11.04’ is available". You can alternatively run "update-manager -d" command to get this option !

Some Random Stuff

1. In case, Unity does not work for you , you can fall back to Ubuntu Classic. In the login screen, select your username and press enter. The control will go to the password textbox. Now, at the bottom of the screen, you will see a session selector. Select "Ubuntu Classic". This will allow you to have the classic GNOME-ish desktop.

2. One of my favorite Linux utilities – hamster-applet is not working in Natty due to the whole Unity and common menu thing. I need to figure out a way to make it work. There is a launchpad bug[https://bugs.launchpad.net/ubuntu/+source/unity/+bug/686062 ] which discusses the alternatives. Subscribe if you are interested.

3. The transition to Unity was very hard for me. This is especially true because I was a keyboard heavy user with lot of custom key bindings. Suddenly, all of them were useless. Even more annoying was the fact that GNOME-Do was not getting invoked when I pressed Super+Space as Unity gobble the keystroke. Unity did have a "gnome-do’-ish dash but it was a bit awkward to me. It was quite annoying when I have to remember that I need to press Alt-F2(Super-A) for searching applications and Super-F for files and folders. GNOME-Do has a more unified interface which is also more customizable as of now.

4. The fact that Unity uses the Super (Windows) key wrecked havoc on my keyboard shortcuts. In addition to GNOME-Do, I had other shortcuts like Windows-G for gedit, Windows-C for Chrome etc. So I searched a lot to find how to change the Unity’s default activation key. Most of the results were crap. The best result is given by this gem : http://askubuntu.com/questions/29553/how-can-i-configure-unity . Basically, you need to install ‘CompizConfig Settings Manager’. Invoke it and search for Unity. Click on ‘Ubuntu Unity Plugin’ and in the behavior tab, change the setting for the entry ‘Key to show the launcher’.

5. Some excellent links that details keyboard shortcuts for Unity are : http://askubuntu.com/questions/28086/unity-keyboard-mouse-shortcuts and http://www.multimediaboom.com/ubuntu-11-04-unity-keyboard-shortcuts-key/ .


Hope you have fun with Natty. I will put out a post soon on customizing Unity for power users.

Read Full Post »

I am primarily a keyboard person and like to have as many keyboard shortcuts as possible – I used a variety of tools for this end ranging from Autokey, GNOME-Do etc. Specifically, I was using AutoKey for many of keyboard shortcuts to invoke applications  – eg Windows+g for gedit, Windows+c for Chrome and so on. The basic idea was to create a Autokey script and use Python’s subprocess module to invoke the application. For details refer my old blog post on AutoKey.

Recently, I bought a new laptop and did a fresh install of Ubuntu and other applications. I am still tweaking it to increase productivity. I noticed that GNOME now allows you to set arbitrary custom keyboard shortcuts in a easy fashion.

The way to add additional custom keyboard shortcuts used to involve muddying around with gconf-editor or xbindkeys. Now it is dramatically easier. Invoke System –> Preferences –> Keyboard shortcuts. You can use this window to modify keyboard shortcuts for certain preexisting entries – For eg I set starting a new terminal to Alt+F3 instead of Ctrl+Alt+T (see option ‘Run a Terminal’ under ‘Desktop’ in the shortcuts window).

To add a shortcut for arbitrary action that is not listed , click on “Add” button. You will get a new dialog with two entries : Name and Command. Let’s suppose I want use Window+g to start gedit. So in Name enter “Gedit” and in Command enter “/usr/bin/gedit” . Press “Apply” . Now you will see a new entry in the “Custom Shortcuts” section. You can click on the shortcut section and enter some keyboard shortcut. In my case, I entered “windows+g”. Typically, Windows key shows up as Mod4.

I like this new mechanism as it is much cleaner, intuitive and user friendly.  I decided to write this post as most top results in Google for ‘custom keyboard shortcuts in Linux’ kept pointing users to solution using gconf-editor or xbindkeys. They do have a role , but I am sure most users will be will more than happy with this GUIsh way.

Read Full Post »

GNOME Activity Journal and Zeitgeist are some of the fascinating recent projects in Linux. I have been a user from their initial versions and have been intending to write a tutorial on it. Two reasons I kept postponing it : GNOME Activity Journal kept changing very frequently and writing a comprehensive Zeitgeist tutorial will take too much time given its potential ! So I decided to split my tutorial into two parts : A basic tutorial on GNOME Activity Journal, Zeitgeist and Sezen and a more geeky post on Zeitgeist in the near future.

[Update Jun 24 2011] : Updated information about Activity Log Manager and data providers.

Why are Zeitgeist and GNOME Activity Journal so cool ?

I will make an assumption here that the reader is a relatively active user of Linux. Everyone knows Linux is cool, secure and blah blah but it is still does not have enough traction in Desktop. Sure Linux dominates in servers and embedded systems but Desktop is where the mind share is. I will not say that Linux Desktop is hard to use but we have not provided compelling reasons for people to try it out. Recently, there has been some effort to make Desktop more user friendly, especially from Ubuntu and Fedora – Let the force be with them 🙂

If you have been following GNOME, you would have heard the term "Document Centric GNOME" thrown around often. If you want, take a look at this insightful (though sort of outdated) GUADEC presentation that started it all.

One of the important problems in Desktop is finding the files you used to perform some task – This is not necessarily the files you used today morning or yesterday. If that is the case, you can always take a look at recently used documents. Let us take few examples :

1. Where are the set of pdf files I used to learn Gaussian Processes last week ?

2. When I was fixing an issue in Chrome Nanny last month what were the files I kept opened in Vim ?

3. I want to buy the book I checked out in Amazon last week. What is its url ? It must be in my web history – But wait was it in Chrome or Firefox?

4. How many excel sheets did I look at last week ? Where are they all located ?

5. Last friday, I listened to some awesome songs in Rhythmbox and I want to listen the same set of songs again. How do I find out all the songs that played then ?

6. More generally, I performed task1 under some context – which involves set of files, websites and other stuff. Note that it is application independent and might involve multiple applications. It must be possible to get into that context anytime I want effortlessly.

These are some of the common scenarios that occurs to us. But no OS has so far provided any convenient way to solve them. Of course, the usual answer is to organize your folders properly or keep a note of things you did. These are not solutions at all. If I organize them properly then each file will be nested deeply and remembering the organization becomes a pain. The folder paradigm is useful but not very intuitive or convenient for users. Remember that for a lot of people (ignoring techies), using Computer is usually a means to get some job done. They are not obsessively focused on organizing the computer. They have a job to complete and we must make it as simple as possible for them to complete it.

Just think how it is done in the real world. You always have an option of filing all the necessary items into a locker so that you can find it later. It must be possible to do the same in a computer : create a task context, view previous activities etc. Zeitgeist and GNOME Activity Journal are some of the tools that will help you in that quest. For some more exotic scenarios , check out the usecases in Zeitgeist vision document. Very few of the usecases can be realized immediately through them but the underlying framework is robust enough to support all of them and more ! GNOME 3.0 has some grand ideas on transforming the Desktop as we know. IMHO, Zeitgeist , GNOME Activity Journal , GNOME Shell are going to make using Linux really cool.

High Level Overview of Zeitgeist , GNOME Activity Journal and Sezen

Zeitgeist is a tricky thing to nail – You can consider it as a daemon that stores all the relevant "events" in your computer. Events can be as simple as user opening a file or browsing to a site or something more complex. Zeitgeist silently stores all the events in its db. The information stored can be arbitrary – it can be as simple as filename or as complex as the entire file content and metadata. Some of the possible metadata include tags, geo location etc. Zeitgeist exposes an API that allows other data "providers" to save and query events. It is the underlying framework over which other cool tools can be written using its API or extended using plugins. Informally, Zeitgeist shuns the folder paradigm and embraces a timeline/task based paradigm. This is a powerful idea as it provides you an additional dimensions (time, context) to browse the files , in addition to folder structure.

GNOME Activity Journal is an "activity browser". It allows you to view in a timeline all the activities you did in the past. Note the emphasis on activity. Potentially an activity can be any interaction with some resource. The activity can be as simple as viewing a file or chatting with a contact. In the future, activity can be as complex as you want. The journal will allow you to search for past activities, filter activities based on source , annotate the activities and so on. Timeline is not the only way to view the files/activities. You can find them by mode of use or even tags that are manually annotated. Infact, it even has a cool feature where it "infers" related files based on usage patterns.

Sezen is a neat applet that allows you to search for activities/files in a convenient way. The search in Zeitgeist sort of sucks now and I use Sezen to fill the void. I hope that the journal will have a more powerful and convenient search mechanism.


Hopefully your interest is now piqued. You can always install Zeitgeist and GNOME Activity Journal from the Ubuntu repository , but it is usually stale. If you are ok with it use the following instructions to install it.

sudo apt-get install zeitgeist gnome-activity-journal

If you want to enjoy the latest features without waiting for a new version of Ubuntu, then add the zeitgeist ppa to the list of repositories. The steps are :

sudo add-apt-repository ppa:zeitgeist/ppa

sudo apt-get update

sudo apt-get install zeitgeist gnome-activity-journal

Some time ago there was a bug where due to some issue in Zeitgeist, GNOME Activity Journal will not start. If I am right, the reason was that when Zeitgeist was updated, the daemon was still running with the old version . If you are bitten by that bug, either restart the system. Alternatively, run this command :

zeitgeist-daemon –replace &

Sezen is a utility that allows you to view the recently used files in a convenient fashion. Some of the functionalities of Sezen overlaps with that of GNOME Activity Journal. When the journal’s search becomes more useful, Sezen may not be needed. Assuming you have installed the PPA, you can install Sezen by

sudo apt-get install sezen

GNOME Activity Journal

GNOME Activity Journal is an "activity browser". It helps you to browse your recently used files, websites or contacts. The information is presented in a chronological fashion. It integrates tightly with Zeitgeist and tracker . As one of the website put it , it is a "viewport to the past". You can access it from Applications > Accessories > Activity Journal.

Multi View

The journal has three different views – multi view, thumb view and timeline view. The default is the multi view which allows you to see the details of 3 days at a time. So your screen will look something like this :

GNOME Activity Journal Multiview

You can immediately notice some things : Information about the last three days are displayed. If you have used in extensively, then information is categorized into files accessed in morning, afternoon and evening. This means that it is now easier to view the files you accessed on morning of 16th of last month. What is more : the journal also classifies files based their type. So you can see that there are atleast 3 different types of file type : You have sections like "Edited or Read documents", "Worked with Images" and "Conversation with contact". As you have different types of data providers, you can view them in a more granular way. Examples include audio,video and websites. Hovering over one of the items will show the preview of that item. So you can immediately take a peek at the item’s content. Of course, you can always click on the item and it will open up in the appropriate application.

You can also see the arrow buttons on the either side of the screen that allows you to navigate across the timeline. If you take a look at the bottom panel, there is a bar chart which depicts the user activity. You can go to any past time by clicking on the appropriate bar. For eg, you can click on somewhere in the middle of bottom panel for August to look at the journal for that time period. If the date you want to check is long back, then click on the left edge of the bottom panel and it will take you back in time in a faster scale. Once you reached the month and approximate date, you can use the right/left arrows to go to the exact timeline. The bars highlighted in orange indicate the dates that are shown in the multiview.

So if you want to know which images you checked out on say Oct 1 2010, all you need to do is to go to that date – either using bottom panel or the navigation arrows. Now expand the itemset "Worked with images" and you will find all the images you viewed on that day. You can always click on the arrow icon on the toolbar to get the current day’s details.

Thumb View

Thumb view is another commonly used view. This is especially useful if you viewed lot of images or videos. You can notice that thumb view is available for only single day. You can still the arrows or the bottom panel to navigate to other days.

GNOME Activity Journal Thumb View

Timeline View

This is my favorite view as it packs lot of information in a concise fashion. All the items are show one by one and near each item there is a blue square to indicate the time it was accessed. For eg you can infer that I accessed gBlogStats.ods somewhere around 11 AM on Oct 9 twice. Similarly, I accessed the file gblognotes.txt intermittently starting from early morning 1 AM till around 8 PM. Each of the blue squares indicate one access. It can either viewing the file or saving it. Using this you can answer the question how many time did I access a file or go to a website. Very neat !

GNOME Activity Journal Timeline View

Pinning Items

Some times you may think that few of the items are important and want to highlight them separately. In GNOME Activity Journal , it is done via pinning the item. So, right click and item and select "Add Pin". This item will be now highlighted at the top separately. You can again right click on the item and select "Remove Pin" to bring it back to original status. Alternatively, you can click on the pin icon of a pinned item to unpin it. You can notice that pinning applies only to Multi View. Also pinned items show up in the slot for "Today". This kinda make sense as the journal typically opens show today’s details and you have an one click access to it. I hope they soon add a feature where I can highlight few items that is specific to a day.

A image showing a few pinned items and about to add pin to another item is shown below.

GNOME Activity Journal Pin Item

Searching Items

There are two major ways to filter items in GNOME Activity Journal. One is the temporal way where you want to see all websites you accessed on Sep 1 2010. If this is the usecase, you can use the naviagation arrows or the bottom panel to go to the appropriate date and see all the files. Another alternate way is to see all the file with "blog" in their names. If this is your usecase, you can use search icon at the toolbar. Clicking it will display a textbox and a dropdown showing the various types of items. So this means that I can filter an item based on partial name and also its "type". As you can see in the screenshot , there are lot of different types of entities ranging from documents , email, notes, chat conversations etc. A screenshot showing a search is shown below :

GNOME Activity Journal Search Items

Note that you can search items only in the multi view. When you enter a query and select the appropriate type, the journal highlights the selected files with a bold blue font. This is where I personally feel GNOME Activity Journal has dropped the ball. When you filter an item, it does not show a new screen which lists the match items in a timeline. Instead it maintains the same multi view and just bolds the filtered file. What is worse is that if I want to find if I had accessed the filtered file last week, I have to manually scroll. In one of the screencasts, it was claimed that when a particular day has a file that matches the filter, it will be highlighted in blue. I am not fully sure it works correctly.

There are multiple ways in which you can improve this page : For eg having separate time line for search results , or atleast highlighting days with matches in blue, using tracker/ fts plugin so that I can search the content, use tracker so that tags work in search etc. I am sure that these minor issues will be fixed soon. Till then you can use Sezen to work around the journal limitations. Look at the section on Sezen for additional details. If you want to do a full text search then use tracker. Please see the section on Tracker for additional details.

Tags And Related Files

Another neat feature of Zeitgeist is allowing you to tag files. I believe this is done using Tracker internally. To add tags to an item, right click it and select "More Information". This will open a new dialog like the one shown below.

GNOME Activity Journal Tags

You can see that tags for the file can be entered one by one on the textbox. You can also delete any previously added tags. In the same dialog, you will see an interesting feature – "Used With" . If I use the files in a group, then Zeitgeist will recognise it and show it. Of course, it might have some noise, but most of the times it is bang on. For eg, I usually use the file "gblognotes.txt" as a scratch pad where I jot down all my ideas , basic structure etc. "gblogpost.txt" is the file where the actual post is written. The other two ods files were used to track blog related statistics. They have lot of co-occurrence and thats why Zeitgeist recognised them. The last three are essentially noise which might have occurred because I used them concurrently. It should be interesting to see if these items will go off when they do not co-occur frequently.

Another neat feature is that any tags that get added here gets reflected in the file’s tracker property page. For eg, right click on the file for which the tags were added. If you had tracker, then you will see a new tab called "Tags". Browsing it you can see that the added tag is checked. As an example, in the screenshot below, you can see that the file has "blog" tag enabled.

GNOME Activity Journal Tracker Integration

Controlling Zeitgeist logging using Activity Log Manager

Sometimes you feel that the relentless logging of Zeitgeist is a bit too much. There might be three different scenarios .

(1) You want to delete some past event from Zeitgeist log

(2) You want to stop entire Zeitgeist logging for some time.

(2) You want to instruct Zeitgeist to never log certain (types of) files.

The first is easy to perform. Once an item is added to the journal, you can always right click it and say "Delete Item from Journal". This will remove it from the list. There is also an option "Delete all events with this URI". This deletes all the events corresponding to a certain file from the logs. The primary inconvenience with this method is that if you want to delete lot of files, then you have to go about it manually.

When this article was first written,  there was no elegant way to control the logging, short of coding it yourself. Recently, the developers released Activity Log Manager that provides a reasonably convenient mechanism to achieve that.

If you are using the Zeitgeist PPA , the software can be installed by

sudo apt-get install activity-log-manager

Once installed, it can be invoked by “activity-log-manager” from the command line. There are multiple use cases that are handled by this tool .

(1) Pause Zeitgeist logging temporarily

Sometimes, you may want to temporarily stop Zeitgeist from logging. For eg, sometimes, I grade students homeworks and do not want them to enter the logs. In scenarios like this, you can stop it by invoking “activity-log-manager” and clicking on the button that looks like a tick. In the screenshot below, it’s the button near “Logging Active”. This will stop the logging till you enable it or restart the computer (or log back in).

(2) Deleting Previous Zeitgeist Events using History tab

If there is some time interval within which you want to delete all events logged by Zeitgeist , you will be using the “History” tab. The log manager conveniently gives two options : One is to delete the events in the past few minutes/hours/days etc. The other is to give explicitly the date range. Most of the time this should do the trick.

There are some slight inconveniences though. If you want to partially delete events then you are stuck with using Activity Journal. For eg, if I want to delete few events from the last 15 minutes but not all then its not possible from here. The second issue is that the more general option for making Zeitgeist forget events only accept dates and not time ranges. For eg, I cannot currently delete events from say Jun 22 1 PM to Jun 23 4 PM . Hopefully this will be fixed in the future. The screenshot is below.

Zeitgeist Activity Log Manager History Tab


(3) Blacklisting Zeitgeist Events from an Application using “Applications” tab

If you want to prevent events from a specific application from entering Zeitgeist logs, then use the “Applications” tab. This tab allows you to add events from known applications. Clicking on “Add” button shows a dialog with known applications and selecting it prevents events generated from that application from entering the Zeitgeist logs. You can add as many applications as you want.

Currently, this shows only the applications that have .desktop entries. And it is not possible to add custom applications. The list of applications are not sorted. It has a rudimentary prefix match support. For eg, if you want to block Google Chrome typing a prefix like “goog” takes you to it. Typing a non prefix like Chrome does not seem to work. The screenshot shows the tab with the list of applications.

Zeitgeist Activity Log Manager Applications Tab


(4) Blacklisting  or Preventing Zeitgeist Events from a folder or file types using “Files” tab.

This is the final use case. Sometimes you may not want Zeitgeist to log events from some folder. Or may be you do not want Zeitgeist logging your music events. The “Files” tab allows you to do it.

The files tab is broadly split into two blocks. In the first block, you can block events from certain types of files – Like audios, text files, videos etc. I am not sure if you will ever want to use this broad a blacklist as it negates the use of Zeitgeist , but I am glad the developers provided this option.

The second block allows you to enter a set of folders such that any events under those folders do not cause Zeitgeist events. You can use the dropdown to select either few pre specified folders or use the “Other” options to select an altogether new folder. In the screenshot below, I have selected temp folder to be blacklisted. This is my scratch folder for my programming and do not want them to be logged as they will be anyway deleted soon !

Zeitgeist Activity Log Manager Files Tab


Hopefully, these options satisfy most of the potential use cases. Zeitgeist is a cool idea and once it has the log manager , it is even more cool !

Before we discuss slightly more techie stuff, let me discuss two other tools that work in conjunction with Zeitgeist and GNOME Activity Journal – Sezen and Tracker.


Sezen is another neat utility that internally uses Zeitgeist. It is similar to GNOME Activity Journal in the sense that it also allows you to "browse" files. But it is more heavily oriented towards searching. To install Sezen enter the following command in the terminal :

sudo apt-get install sezen

Unfortunately, it does not have a menu option to launch and must be invoked from commandline. Of course, you can always add an launcher. To invoke it , type in a terminal :

sezen &

This should start Sezen. You can notice that the screen looks remarkably pithy. It just has a textbox to enter query and few options to narrow down the filter. When you enter a query, all the results are shown organized by time. All files accessed today, yesterday, last week, last month etc are grouped in a temporal fashion. This is kinda the interface that I want Activity Journal to sport. Sezen also has a more sophisticated search than activity journal. As an example, I entered my query as blog. Files like "gajSezen.png" are selected even though it does not have the word "blog" in its name. The reason is that I have placed these images in a subdirectory of "blog" folder (ie blog/gaj/gajSezen.png) . This is very useful because you enter some search query for a directory and find which files you accessed recently and when. Neat !

GNOME Activity Journal Sezen Search

Of course, there are lot of places where Sezen can improve – I do not think Sezen uses tracker’s full text search. It would be awesome to merge temporal, folder, content information and provide an unified search interface. Even better will be merge it with GNOME Activity journal. Similarly, it is not possible to select all images and documents. The filters behave like exclusive ones. If they can behave like checkboxes then it will be cool !


Tracker can be considered as a search engine for your local file system – in other words a desktop search utility. So far all Linux desktop search utilities suck. The recent versions of Tracker seem to be okay. GNOME Activity Journal uses tracker for search. Tracker can index files in your system and also their content. It has a full text search (fts plugin) that allows you to search based on their content,name and path. It can index a variety of file formats. One limitation of GNOME Activity Journal and Sezen is that they do not perform full text/content based search. If you want to find all the files that contain the word say "Gaussian Processes" then tracker is the way to go . Tracker is a dependency of Journal and must be installed with it. You can access it from Applications -> Accessories -> Tracker Search Tool.

GNOME Activity Journal Tracker Search

You can find that Tracker interface is remarkably similar to GNOME Activity Journal or Sezen. I have given a search query of blog and you can see that not only it displays files with the word "blog" in their name but also the files which have the word "blog" in their content. So you can filter the results based on their file type : like documents, images etc

Now that we have covered the basics of the tools, lets delve into the details.

Data Providers

There are lot of tools that send their data to Zeitgeist without you doing anything on your own. For other applications they must be patched so that the data can be sent to Zeitgeist. Note that the information transfer can happen both the ways : Applications can send the files accessed to Zeitgeist and they can also get information about the file usage. eg Rhythmbox can use Zeitgeist to find the most used music files or the music files that are listened together. The potential is endless.

Lot of the applications though must be modified to send the data to Zeitgeist. Previously, there was a bunch of scripts that you must download to patch the applications to send their events. Now these scripts have matured and have become Linux packages on its own.

To install data providers, start synaptic and enter “zeitgeist-datasource” in the search window. You can see a huge list of applications for which providers are available like Vim, Emacs, Rhythmbox etc. Install the data sources for which you want the events to logged .


Zeitgeist – Docky Integration

If you are using Docky to have a jazzy dock in your system then you can make it even more cool by integrating it with Zeitgeist. To do that right click on Docky icon and select Settings. Go to the Docklets tab and enable the Recent Documents docklet. Go to Helpers tab and enable "Zeitgeist Integration" and "Zeitgeist Journal".

Now when you right click on any application icon in the dock (whether they are running or in dock already) you can see two new menu items : "Most Used Items" and "Most Recently Used Items". So if you want to open a file in gedit, right click the icon and select the file from the most used list and watch it open ! If Docky makes life easy, Zeitgeist integration makes you feel the joie de vivre.

Techie Stuff

1. If you are curious about the event flow, you can run Zeitgeist daemon in the command line. It outputs lots of verbose output and I learned lot about its workings from it. For eg in a terminal enter the following and go about your business. The logs will be displayed in your terminal.

zeitgeist-daemon –quit

zeitgeist-daemon &

2. Zeitgeist, GNOME Activity Journal, Sezen are all written in Python and are relatively small projects. Spend an evening skimming through the source files.

3. If you want to find how activities are stored internally check out the folder ~/.local/share/zeitgeist/. Specifically, take a look at the file activity.sqlite .

4. All the black listed items are encoded in JSON format in the file /home/neo/.local/share/zeitgeist/blacklist.json .

Potential Applications

The post Integrating Zeitgeist into GNOME contains lot of excellent comments that indicate the potential applications of Zeitgeist. I have copied my favorite comments verbatim from there :

1. Imagine that smart playlists are powered by zeitgeist. You would get a whole slew of new options like "Songs I listen to while chatting with Babes" or "Songs I never listen to in the office".

2. Show you top 20 most listened song for the week/month/year and also show songs you never listened too.

3. If both Rhythmbox and Banshee would have been integrated with zeitgeist, we could have had (for an example) a playcount synchronised for every song. It would be useful when creating new dynamic playlists.

4. Software Center in Ubuntu can display the application usage count. For eg, this can indicate unused applications to customer which can be uninstalled to free space. Alternatively, you can collect apps in to groups and use the co-installation and usage count to recommend new packages to users. Isn’t it cool !


Zeitgeist , GNOME Activity Journal and Sezen are few of the GNOME utilities that I am pretty excited about. Even though their current features are limited, they have enormous potential and can be used to develop really cool applications. I have few plugins in my mind – for eg enhancing GNOME Do with Zeitgeist and few other plugins. I will write a post once something concrete is done.

Each of the tool has its own use. So use GNOME Activity Journal for finding which files you accessed when (even at granular level like which hour). If you want a more enhanced and generic search use Sezen. If you want to search based on their content then use Tracker.


1. GNOME Activity Journal – Contains lot of useful links and the usecases.

2. Zeitgeist – The magic tool behind GNOME Activity Journal and Sezen.

3. Sezen – No specific URL. Lot of useful posts in the link.

4. Tracker – Another neat project that GNOME Activity Journal internally uses and provides full text search.

5. Seif Lotfy’s blog : Has lot of useful news on Zeitgeist.

Read Full Post »

Prelude : My blog has been silent for quite some time. I was busy with my Masters thesis for couple of months. I am starting with my PhD , wrapping up things and slowly getting into the groove. I hope to settle into a routine where I have one long blog post per week. Let us see how it goes !

    Nautilus is one of the most commonly used file manager for GNOME. One of the reasons for its popularity is its extensible architecture that allows developers to write scripts to customize it. Even if you are a command line person, extending Nautilus will result in dramatic increase in productivity. In this post, I will discuss the multiple ways in which Nautilus can be extended and the relative merits in each approach.

    The first step in extending Nautilus is to find the set of actions that are tedious (atleast not straightforward) – Tasks that need additional clicks or switching to terminal to get completed. The next step is to determine if there are command line tools available to automate the task or the task can be completed by additional code – Again since you are extending Nautilus, the task involved has to relate to files or folders. For eg, opening a file as administrator is a "relevant" task but starting a nuclear war from Nautilus is not !

Informally, it is easy to extend Nautilus if your task falls in the following categories : Adding new entries in context menus (or in toolbar) that involve selected files/folders or current folder, add additional custom properties to files and display those details in list view, modify the properties page to display additional tabs with information etc. There are other possibilities but these are the most common ones.

    If the above discussion sounds very abstract let us give some examples :
1. Open a terminal in the current folder or open the selected file as root.
2. Selecting a few audio files and adding them to Rhythmbox "Now Playing" queue.
3. Selecting a few files and sending them to thunderbird for attachment
4. Display IMDB details about the selected movie file in the property page etc.

The above examples show a gradient of use cases in the order of complexity. Some of them are so simple that they can automated using simple means. Tasks like (4) are tricky and need powerful tools. Selecting the right tool is important and we will discuss how to select the best approach.

Different Approaches to Customize Nautilus Context Menus

Like everything in Linux, there is always a variety of ways to customize Nautilus ranging from simple to complex. In this post, we will discuss the three most common approaches :
1. Using tools like nautilus-actions
2. Using Nautilus scripts
3. Using extensions written in nautilus-python

As before, all my discussion will be focused on Ubuntu but it should be relatively easy to apply to other Linux distributions.

Customizing Nautilus context menu using  nautilus-actions

This is probably the easiest method. All you need to know is the shell command or script to perform the task. Nautilus actions provides an intuitive GUI to decide on the filters and the actions to be performed. This approach works best if the following conditions are met :
a. the task you want to be automated is easily translatable in command line
b. the command line utility accepts the arguments in a relatively simple form (eg space separate arguments etc)
c. The command line utility depends only on information pertaining to the selected file/folder.

To install the package, type the following at terminal (or install this package from Synaptic) :

sudo apt-get install nautilus-actions

Once the package is installed it can be accessed at System -> Preferences -> Nautilus Actions Configuration. I will only give a basic discussion here as there is a decent tutorial on how to create a new action at How To Add Custom Functionality To Nautilus.

Let us take a simple example – If I right click on a folder , I want a new menu which says, "Open Terminal Here" and when it is clicked, a new terminal must be opened and the working directory of the terminal must be the selected folder. The first step is to find if it can be expressible in a "single" command. Find the name of the command to invoke the terminal – it is called gnome-terminal. Read the man page to find that it accepts an argument "–working-dir". When provided, it starts the terminal in specified folder.

Now start the Nautilus Action from System -> Preferences -> Nautilus Actions Configuration . The steps are :
a. Create an action.
b. In "Action" tab, give the action some name and select "Display item in selection context menu". If you want it to be visible in the toolbar, it can done too ! Select "Display item in toolbar" and choose some icon.
c. In the command tab, give "gnome-terminal" as path and parameters as "–working-directory=%d/%f". The %d and %f are special codes that will be expanded when the command is invoked. To see other special codes and what they mean, click on the "Legend" button.
d. In "Conditions" tab, select "Only Folders".

Now open a new Nautilus window , select a folder and right click. Presto ! You will see a "Open Terminal Here" menu. Select it and you will see a new terminal open with the selected folder as its current directory !

Some Notes On Nautilus-actions

You can take a look at Nautilus-actions project page to find lot of actions that automate your common tasks. To include them in your system, download the schema and then import them. To import, Tools -> Import assistant -> select the schema file. There are literally hundreds of nautilus actions that you can use immediately.

Nautilus Actions is a very nifty GUI tool that makes creating context menus dramatically easy. The best part is that specifying the command and filters is very intuitive. I will say that for a vast majority of scenarios, Nautilus actions is all that is needed to automate some task. But the simple nature of the tool is also its biggest enemy – there are some tasks that are slightly more complex and nautilus action is not very useful in them. A simple example will be a task which needs two commands to complete. Consider task (2) above – Adding selected mp3 files to Rhythmbox queue. The problem here is that if the file is not already in the library, Rhythmbox will not add them to the queue. So this needs two commands – one to add them to library if not already present and then add them to queue. Tasks like this are tricky to implement using Nautilus actions.

Another class of tasks that are not solvable using Nautilus actions is the ones that have tricky input formats. If you go the "Command" tab and click on "Legend" button, you can see that the list of special codes available are limited. They satisfy majority of needs but not all. Let us take a simple example , say task (3) – send selected files to thunderbird as attachment. Thunderbird has a command to compose a new mail with attachments but the arguments must be "comma" separated. In this case you are out of luck with Nautilus actions and must look at more powerful tools.

Nautilus Scripts

Nautilus has an extensible architecture that allows scripts to be executed. There is usually a misconception that Nautilus scripts has to shell scripts. That is no longer the case. Nautilus allows you to run scripts written in any language as long as they are executable and it knows which program to invoke. This means that you can write scripts in shell , python, perl or any other language as long as the first line of the script says which program Nautilus will have to invoke to execute the script (ie the shebang line).

You can consider that Nautilus actions provides a convenient wrapper over Nautilus scripts .The statement is not exactly true , but it is a good start. Before discussing Nautilus scripts, let us compare the two approaches – Nautilus script allows you to do certain things that are not possible in Nautilus actions. For eg, you can have a huge shell script with multiple lines that gets executed instead of a single command. In my opinion, another important advantage is that it is possible to invoke a Nautilus script without selecting a file – For eg one that runs using just the current folder information. This is not possible in Nautilus actions. On the down side, scripts are always available. It is not possible to show a Nautilus script for only mp3 files or only for local files. Another issue is that Nautilus scripts are most useful for local files and folders. For remote files (eg ftp , smb or webdav) they are essentially useless – but Nautilus action based commands will work fine in this scenario.

How to write Nautilus Scripts

All the Nautilus scripts are in the folder $HOME/.gnome2/nautilus-scripts . You can access them in command line or by File -> Scripts -> Open Scripts folder. Alternatively, you can right click on a file/folder and select Scripts->Open Scripts folder from the context menu. Note that the scripts menu will be available only if you have some scripts in that folder.

To write a new script, create a file in $HOME/.gnome2/nautilus-scripts and change its permissions so that the "user" has executable permissions. Make sure that you have a shebang line which tells Nautilus which program to invoke to run this script. If you want to organize your scripts then create subfolders in the nautilus-scripts folder. All the subfolders become sub menus in the Nautilus context menu.

When your script is invoked by Nautilus , at the most 4 environmental variables will be set by it. They are NAUTILUS_SCRIPT_SELECTED_FILE_PATHS, NAUTILUS_SCRIPT_SELECTED_URIS, NAUTILUS_SCRIPT_CURRENT_URI and NAUTILUS_SCRIPT_WINDOW_GEOMETRY. NAUTILUS_SCRIPT_SELECTED_FILE_PATHS and NAUTILUS_SCRIPT_SELECTED_URIS are newline delimited variables about the selected files. The only difference is that one gives the name of the directory and other gives it as a URI. ie for a local file /home/blah/abc.txt , the first variable will /home/blah/abc.txt  and second will give file:///home/blah/abc.txt . NAUTILUS_SCRIPT_CURRENT_URI gives the URI of the current location.

You can immediately see that the information available is pretty limited. You have to write the script using only these variables. The information is available as environment variables in shell script. For other languages, you may have to use additional modules to access them. Once you have written a script, it is time to test it ! The steps are :

a. Open a terminal and type "nautilus -q". This will close all instances of Nautilus.
b. Type "nautilus –no-desktop" . This is very useful when you are developing the script as it open Nautilus without opening your profile or preference data reducing the chance of data corruption.
c. Right click on a file/folder. You will notice that a new "Scripts" menu comes up and it has your script as the submenu. Selecting it will run your script with the options. You can alternatively run the script from File -> Scripts.
d. If you want to run a script without running on any specific file/folder, invoke the script using File -> Scripts. You must note that in this case only NAUTILUS_SCRIPT_CURRENT_URI will have meaningful value.

Debugging Tips for Nautilus Scripts

It is possible that your scripts may not work the first time. There are no easy way to debug the scripts. Here are some ideas that I find useful :

Case 1 : The script does not appear in Scripts menu (or the scripts menu itself does not occur)
1. Have you placed your script in $HOME/.gnome2/nautilus-scripts ?
2. Does it has executable permissions atleast for the user ?

Case 2 : The script appears in the menu but does not seem to work correctly
In this case, the bug is most likely in the logic of the code. Comment your entire script logic except the shebang line. Add few lines to echo the values of the environmental values into some file in say /tmp/blah. Quit nautilus and open it up. Execute the script. This will result in the arguments being dumped into the log file. Now manually set the environmental values with the values in log file and try executing the script from command line. Since we have the values of the environmental variables, we can simulate Nautilus execution from command line. Most likely , this will allow you to find the issue and fix it.

Notes on Nautilus Scripts

A huge list of Nautilus scripts are available at g-scripts page . Download the file
nautilus-scripts.tar.gz . Even though the information available to scripts are limited, many of them use shell commands in innovative ways. For eg, they use gdialog or zenity to show information graphically. Browse through the scripts to get an idea of what is possible using Nautilus scripts.

Nautilus scripts brings certain advantages and disadvantages. On one hand, they allow more complex actions to be performed. They are not limited to have only single command like Nautilus actions. They also can be executed without selecting any files. But the information available to the scripts is very limited – only 4 environmental variables. Also they are not useful when you invoke on remote files. It is also not possible to show the script only to files with selected attributes (eg only audio files). Of course, you can always return prematurely for files not matching your criteria but it is unnecessary work that must be repeated for all files.

Nautilus Extensions

Nautilus extensions can be considered as the Swiss army knife of customizing Nautilus. They have a relatively steep learning curve but once you learn them , you can extend Nautilus in ways that are simply not possible using other approaches. Nautilus extensions allows you to do tasks that are made possible by previous approaches and more . Some of the things that are possible are :

a) Adding menus for files/folders with certain attributes.
b) Adding new menus in toolbars.
c) Adding new custom attributes to files and folders and using them do perform special actions. It is also possible to display them in the detailed view. A simple example is to add say length of song for mp3 file and show it as a column in Nautilus.
d) Add new tabs in the property page – eg show additional IMDB information for movie files.
e) Add additional information about current location near the location bar.

The classical way to write extensions is in C. But gnome programming in C is bit tricky. I will not discuss them as there are easier ways available. If you are still interested , you can take a look at the Nautilus extensions API reference provided in the Notes section. You will have to compile your extension code and put the executable in /usr/lib/nautilus/extensions-2.0/ .

A cleaner and much easier alternative is to use Nautilus-Python . Nautilus-Python by itself is a C extension for Nautilus. What it does internally is that it exposes a "nautilus" module which can be used by Python programs to write Nautilus extensions in Python. The extension is quite well designed and provides a pythonic interface for programmers. To install this package,

    sudo apt-get install python-nautilus

Nautilus Python Interfaces

1. nautilus.ColumnProvider – This allows your program to give additional columns (attributes) for files in the current location when the user is in List mode. Usually gets the information supplied by nautilus.InfoProvider . An example is to show length of the audio for mp3 files.
2. nautilus.InfoProvider – This file is called on all files that the user is currently viewing. You can add new attributes to the files , add new emblems or perform other tasks. An example is to provide track details about the current audio file.
3. nautilus.LocationWidgetProvider – This allows some widget to appear near the location bar. I cannot think of any practical example for this interface.
4. nautilus.MenuProvider – Allows you to provide custom menus for the selected files or folders. It is also possible to create toolbars or background menus.
5. nautilus.PropertyPageProvider – Allows you to augment existing property page (Right click -> Properties) with additional pages displaying specific information about the selected file. An example is to show MD5 of a file or show IMDB details for a movie file.

Writing Nautilus Python Extensions

You can write Nautilus extensions in Python using the Nautilus-Python extension. The scripts you write has to be placed in $HOME/.nautilus/python-extensions. If you have admin rights, you can also place them at /usr/lib/nautilus/extensions-2.0/python-extensions. Usually I prefer my scripts to be in my home folder.

The development process is very similar Nautilus scripts. The steps are :

1. Create a python file in $HOME/.nautilus/python-extensions .
2. Extend one or more of the interfaces and code the relevant functions in the interfaces.
3. Make the script file as executable.
4. Kill all instances of Nautilus using "nautilus -q" . Note that many web pages asks you to use "killall nautilus" but I prefer my apporach as it allows nautilus to die gracefully 🙂
5. Restart Nautilus. During development, using "nautilus –no-desktop" as it starts without reading profile preferences.
6. Test your extension. This will be extension specific due to the various capabilities of the nautilus python extensions.

A Closer Look at Nautilus Python Extensions

As discussed above, Nautilus Python exposes 5 interfaces. Based on your needs your class will inherit from one or more of the interfaces. Each interface will have few methods where the logic of your extension has to be included. After installation , you can take a look at /usr/share/doc/python-nautilus/examples/ for working examples. You can even copy them to $HOME/.nautilus/python-extensions and play around with them till you are comfortable. If you want to see all the functions that the interfaces expose, un-gzip the file /usr/share/doc/python-nautilus/examples/documentation.py.gz. This will produce a file documentation.py which provides the signature and basic information about the methods exposed by the interfaces. Let us take a brief look at them :

1. nautilus.ColumnProvider – It exposes a single function get_columns . This function has to return a sequence of nautilus.Column objects. As an example, the extension can return information like runtime or codec details for an mp3 file.
2. nautilus.InfoProvider – Exposes a single function update_file_info with a file as an argument. The function can update the file in various ways – for eg, it can set new custom attributes, change emblem or perform other actions on the file.
3. nautilus.LocationWidgetProvider – Exposes a single function get_widget . The function returns some gtk widget which will be displayed near the location bar.
4. nautilus.MenuProvider – Probably the most used interface. It exposes three functions : get_file_items, get_background_items and get_toolbar_items . The first two functions determine the entries that appear in the context menu. The difference is that get_background_items is usually called for a folder. The last function is used for toolbar items hence you must name the icon parameter of the menuItem.
5. nautilus.PropertyPageProvider – Exposes get_property_pages function where you reture one or more "pages" or tabs. An example is to create a new "IMDB Details" page which shows the movie information.

Debugging Nautilus Python Extensions

Debugging Nautilus Python extensions is pretty tricky. The main reason is that the "nautilus" package that is used extensively in the code is available only when the script is invoked from Nautilus. But all is still not lost. The following are some of the tips I learnt when I built my library of Nautilus extensions 🙂

Case 1 : You wrote a code for new entries in context menu but it either does not appear or works incorrectly 
1. Is your script in $HOME/.nautilus/python-extensions ?
2. Is the script has its executable bit turned on?
3. Did you restart Nautilus ? (using nautilus -q and nautilus –no-desktop )
4. Check if the file is compiled in extensions folder – basically is there a .pyc file ? If not invoke the file with python to find the syntax error.
5. Import the logging module and check if the relevant functions are called.
6. If you think the menu is being shown incorrectly, then make sure you are using the relevant functions on the FileInfo class. The class has multiple utility functions and deciding the correct one is important.

Case 2 : You wrote a new property page and it does not appear
Try steps 1-5 from Case 1.
6. Check if all the widgets are visible (ie show method is called).
7. Check if the GUI that you try to render works normally. This can be done by moving the code that returns a page to another python file and putting the HBox/VBox into a gtk.window.

Notes On Nautilus Python Extensions

A good discussion about developing the extensions is at Nautilus Extensions. The discussion is primarily for C. A good C API reference can be found at Nautilus extensions API reference. For Python, nautilus-python Reference Manual provides a basic reference.

The reference manuals per se are very skimpy in details. The best way to learn how to code nautilus python extensions is looking at existing code. There are lot of excellent python extensions that you can use for learning. The simplest is the examples provided with the python-nautilus package. The files can be accessed at /usr/share/doc/python-nautilus/examples/ for working examples. To test them copy to $HOME/.nautilus/python-extensions , restart
nautilus using commands provided above. Nautilus pyextensions contains few useful scripts. Download the source code that is available as nautilus-pyextension-<version>.tar.gz file and play around with them. One of the most powerful examples for using Nautilus Python is RabbitVCS. You can take a look yourself at the amazing RabbitVCS screenshots. You can download the source using apt-get source command.

Generic Nautilus Debugging Tips

    I found some websites that mention an alternate way to debug Nautilus extensions. It did not work for me but I will mention it here for the sake of completeness.  Create a file called nautilus-debug-log.conf in your home folder with the following lines :

    [debug log]
    max lines=1000

If Nautilus crashes for some reason, it supposedly writes into the file nautilus-debug-log.txt. If it works for you then great ! You have access to another debugging tool 🙂

Summary and Tips on Choosing the correct Approach

There are three approaches to extend or customize Nautilus. Using Nautilus actions, scripts or extensions. Each of them have their own pros and cons.

1. There is a high likelihood that some one else had a similar problem before. So before choosing one of the approaches, check if the code is available somewhere. Check the discussion (notes section) above for good resources.
2. Is your task very simple? Can it be completed with a single command line utility? Then use the Nautilus actions.
3. Try to complete your task as much as possible using Nautilus actions even if it involves some thing quick and dirty. Most of the case, you are the only person going to use it. One important thing to note is that the command that you provide in Nautilus action can also be your own script !
3. If your task primarily involves invoking multiple command line utilities , needs only basic information about the files and applicable only for local files then use Nautilus scripts.
4. If the task needs execution of multiple commands but need to be used only for certain files (eg only for txt files) , then try to write a script which invokes the appropriate commands. It should able to massage the inputs $* or $@ appropriately. Then use this script as the command to be invoked in Nautilus actions and use the filters to apply it to certain files.
5. If you need to invoke scripts even without selecting any items and the input needed is simple, then use scripts. If more complex processing is needed using extensions.
6. If you need to show the option in toolbar , then use extensions (and implement get_toolbar_items function)
7. If your task is complex – adding attributes to files, adding additional columns , adding new property pages etc use extensions.
8. Using Nautilus scripts does not mean your app is confined to text only. Use gdialog, zenity in Shell scripts for data entry and basic UI. If you use other languages, use the gtk library to develop complex UI. For eg, I have a script that queries opensubtitles.org site for subtitles and shows the result in a gtk window. Selecting one of the results downloads the subtitle file locally.
9. If you are very comfortable with Python, skip scripts and use extensions.

Sample Nautilus Python Extensions

I have a large library of actions, scripts and extensions. In this post, I want to share two of them.

1. Send file to thunderbird as attachment : The task is to select a set of files and compose a mail in Thunderbird with the selected files as attachment. Almost all the scripts / extensions that I see in the net did not work correctly and hence I wrote it myself. This extension will work for single or multiple files. It will appear only if all the selected items are files. It assumes Thunderbird is located at /usr/bin/thunderbird (View File) .

2. IMDB Details Property Page : I wrote this extension as an exercise to learn property pages. It uses the excellent IMDbPY library to fetch details from IMDB. It works only on video files and strips the common unused characters before querying IMDB. Since this was a test, I blindly select the first result and show the details. This extension also uses other gtk widgets to have a more complex UI. Assumes you have IMDbPy and pygtk installed (View file) .

I hope the article showed how to improve your productivity by customizing Nautilus to perfectly suit your work style. If you have any additional tips or ideas please post them in comments !

Read Full Post »

Defcon was held in Las Vegas some time back. As usual there were lot of cool hacks – My favorites were Hacker Spoofs Cell Phone Tower to Intercept Calls and Web attack knows where you live. Both were incredibly clever and a bit creepy.

2. A regular expression to check for prime numbers
This post got lot of attention recently. The claim to fame is a clever (but inefficient) regular expression to check prime numbers. The trick was to represent the numbers in unary format and use regular expression backtracking to check for divisibility. Cool !

3. High-Speed Robot Hand
One of the mind blowing robot demos I have seen.

4. Amazon Prime for Students
This is an interesting move by Amazon to offer 1 year of free prime membership to students. I am not sure what percentage of students will continue with paid prime membership after a year. Usually, the students (especially foreign) students are pretty tech savvy and can search patiently for the lowest price deals. Let us see how successful this program becomes.

5. The Web’s New Gold Mine: Your Secrets
An interesting article series by WSJ that analyzes the amount of cookies and other tracking stuff popular websites uses. I was pretty impressed with the whole article series "What They Know". Check it out !

6. Google News
Update on Google Wave announced the shuttering of Google Wave. I was pretty impressed with the technology and quite sad to see it go. But there have been adequate (less confusing? ) replacements so I am sure most people will not miss Wave. Google will definitely add Wave’s features to other products so Wave will kinda live on.

Another of my favorite post was New Google Buzz API features, including a hose of fire. I have always wanted to play with Buzz programmatically but its limited API was hampering me. Recently, the Buzz API has made impressive strides that I should check it out again. The availability of fire hose is really neat. Lets see if I can build something cool !

7. GNOME Census
This article caused a huge commotion in the GNOME community especially with respect to Canonical. I have to say the census was very interesting.

8. Massive Censorship Of Digg Uncovered
A very interesting article. Looks like there is some organized conservative group that is burying more liberal articles. What surprises me the most is that digg did not have any mechanisms to prevent a group of people gaming the system. If my intuition is correct, it is a relatively simple data mining problem using topic models, anomaly detection and collusion detection/role discovery in relation graphs.

Read Full Post »

Older Posts »