Tuesday, 6 December 2011

Coalescing multiple edits into a single bazaar commit

Occasionally, after committing some changes on a bzr branch, I'll come back to it and want to make further changes.

So, I'll have done something like this:

$ bzr commit
$ # Oops! Forgot to update foo.c. Let's do that now...
$ vim src/foo.c
$ bzr status
modified:
  src/foo.c

But rather than creating a second commit for the newest changes, I'll want to combine those new changes and the changes in the latest commit into a single new commit. How do we do this? With bzr its easy:

$ bzr log -l1 > /tmp/commit.log         # save the latest commit log entry
$ bzr shelve --all -m "latest changes"  # save the latest uncommitted changes
$ bzr uncommit --dry-run                # check its going to work
$ bzr uncommit                          # undo the last commit
$ bzr unshelve --dry-run                # check if its going to work
$ bzr unshelve                          # apply the latest changes to the working directory
$ bzr commit                            # create a new commit containing all the changes
                                        # (here we can make use of '/tmp/commit.log')

Job done.

Thursday, 1 December 2011

Adding an icon in Ubuntu's Unity for applications which don't provide one

Occasionally, when you're exploring the truly vast range of offerings in the Ubuntu Software Archives via the wonderful Ubuntu Software Centre (or maybe via "apt-cache search"), you might find a graphical application that doesn't have an icon. If this happens, there are 2 things to do:

  1. Raise a bug on that application to have an icon added.

  2. Add an icon temporarily.
Raising a bug is easy, just type:

$ ubuntu-bug <thing>

Where "<thing>" is either the name of the program you are running, or the package that program lives in.

However, you can also quickly add an icon yourself using this simple technique...

There are 2 steps:

  1. Select your icon
  2. Create a "desktop" file

Icons are installed in the "/usr/share/icons/" directory by default, so have a browse around to see what you like. If you're still struggling to find an appropriate icon, you could add the package wm-icons which adds over 1500 new ones (!):

$ sudo apt-get install wm-icons

Having chosen your icon, all that remains is to create the "desktop" file in a particular directory to have Unity, the awesome Ubuntu graphical interface detect it automatically! What's even better is that once you've created the desktop file, you can even run the application from the command-line to have Unity "do the right thing" (TM) and display the corresponding icon in the launcher.

Let's assume the application is called "foo". Simply create a file called "foo.desktop" in directory "~/.local/share/applications/".

File "foo.desktop" would contain:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=/usr/share/icons/wm-icons/48x48-crystalclear/modules.png
Name=foo
Comment=my foo application
Exec=/usr/bin/foo

Notes:

  • The icon I've specified above comes from the "wm-icons" package.
  • You will need to change the "Name", "Comment", and the all-important "Exec" keys (or fields) as appropriate.
  • This technique only works for graphical applications.
  • You may need to restart Unity to see the new icon in the applications Lens ("unity --reset")

For all the gory details of "desktop", or "desktop entry" files as they are technically known, see:


Now, you can just run your application by typing "/usr/bin/foo" (the value you entered for the "Exec" field in the desktop file) and see your chosen icon in the launcher on the left of the screen.