After all the terrific feedback and contributions we received from community contributors as a result of my Quicklists article, I’ve been asked to talk about how to contribute to improving another feature of Unity, the Applications Lens.
Search is the heart of the Unity Dash, and making search better is great way to contribute to the overall quality and usability of Ubuntu. And just like Quicklists, there are ways you can do this without being a developer. In this article, I will show you how to add Keywords to an application that will be used by the Dash’s search function.
Just like in my previous tutorial on Quicklists, I will once again be using Geany as my example application since it is one of my most-used programs. Geany will be found in a search for “IDE” or “Development”, thanks to those words being in the Comment and GenericName fields of it’s .desktop file. However, I think it should also be found in a search for “Code” and “Programming”, which it currently does not.
Step 0: File bug reports
This wasn’t part of the Quicklist tutorial, because I had already filed bugs for the apps we were targetting. But this time there is no list, so it’s up to you to make sure there is a bug report. For ubuntu, you can file it against:
It’s equally important to file a bug in the upstream’s Bug Tracker. Refer to the stems up my post about upstreaming your quicklists for how to find your upstream.
Once you have your bugs filed, post a link to them in the comments so that others know you are working on them.
Step 1: Getting the package code
Everything in Ubuntu exists in bzr, which makes getting the source for the package easy. just “bzr branch ubuntu:<project>”. For geany, this is what I ran:
bzr branch ubuntu:geany
If you followed the Quicklist tutorial, you’ll have already done this. However, if your merge proposal hasn’t been accepted yet, it’ll be easier to do these changes on a clean branch. You can give the name of a new directory for this checkout by running:
bzr branch ubuntu:geany ./geany-keywords
Step 2: Adding keywords
Again, just like with Quicklists, you first need to locate the .desktop file for your application. For me, it was located in the root of the branch in a file called “geany.desktop.in”. If you don’t see it in the root of your project’s branch, try running this command:
find ./ -name "*.desktop*"
This may not look exactly like the file in your /usr/share/applications/, since some processing is done to add translated strings for the application name and comments. But as long as you are just adding the Keywords item to the bottom of the file you shouldn’t have to worry about that.
Next you should look for deprecated keyword fields. ”Keywords” is a new part of the XDG specification, but your application may have already been using the desktop-specific field “X-GNOME-Keywords”. If it does, go ahead and rename it to “Keywords”. Also check for the existence of fields starting with an underscore, like “_Name”. If your .desktop file has those, that means it’s probably setup for translations already, and you should use “_Keywords” instead, so that they can be translated as well.
For geany, there was no existing Keywords field of any kind, but it was setup for translations, so I used the following:
mhall@mhall-laptop:~/projects/Ubuntu/unity/quicklists/geany$ bzr diff === modified file 'geany.desktop.in' --- geany.desktop.in 2012-02-24 19:30:41 +0000 +++ geany.desktop.in 2012-02-27 18:31:39 +0000 @@ -10,3 +10,4 @@ Categories=GTK;Development;IDE; MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/xml;text/html;text/css;text/x-sql;text/x-diff; StartupNotify=true +_Keywords=Code;Editor;Programming;
Step 3: Submitting to Ubuntu
Now you need to send your changes to Ubuntu. This is very similar to what we did for Quicklists, but I’ve added one extra piece to the commit command.
bzr commit -m "Add Keywords to .desktop file" --fixes lp:942154 bzr push lp:~mhall119/ubuntu/precise/geany/add_keywords
By passing the –fixes flag, along with your Launchpad bug #, to the bzr commit command, you will automatically link your new branch with the bug report you created in step 0.
The next step is to once again propose that your changes be merged into the Ubuntu package. To do that, run the following command to open the Launchpad page for your new branch:
On that page you’ll see a link labeled “Propose for merging”, click that and fill out the form on the next page to create your merge proposal.
Step 4: Submitting to Upstream
The final step is to send your changes upstream as well. This is good practice whenever you are making changes, plus it makes it easier for Ubuntu’s package maintainers. Since every upstream is different in how they want to get submissions, I recommend following my previous upstreaming tutorial for this step.Read more