I thought I might write a series of blogs about Unity, with each one suggesting ways to make it more comfortable to use. Unity is the User Inteface created for Ubuntu and is the standard UI for 12.10. The complaints about it's design have been loud, but so has the defence from the designers. In the past I actively avoided using it, until about 6 weeks ago when I installed a new machine and decided to persevere with it 'at least until Christmas'.
In this article I'll explain how to setup the Launcher so it works correctly with Oracle's SQL Developer. The techniques apply equally to other applications that may not yet be correctly integrated with Unity's Launcher.
The Launcher is a list of Icons that sits down the left side of your screen and allows you quick access to launch applications, and to bring to the surface already running applications. The problem is that when you install SQL Developer or other apps that are started from a shell script, especially Java apps (Eg IntelliJ), they often don't work correctly from the Launcher.
There are 2 ways to add an app to the Launcher: 1. Run the app from a command line, then, when it's icon is displayed in the Launcher, right click on the icon and select 'Lock to Launcher' 2. Use Dash (Super key) and in the Application Lens (see, I've learnt all the new terms) drag the app's icon onto the Launcher
The second of these options doesn't work at all for SQL Developer because there is no app icon known to the system. The first option sort of works, but not very well. It adds an Icon to the Launcher, but when you click to launch SQL Developer, it fails to appear on the screen. The icon fades in and out a bit, but nothing gets launched.
The solution comes in several parts:
- first, create a ".desktop" file that defines a new Application, including the command to run, it's name, icon and other details
- next, tell the desktop to update it's cached list of known Applications
- finally, use option 1, above, to find the Application in Dash, and drag it to the Launcher
Here are the commands to do this:
sudo gnome-desktop-item-edit --create-new /usr/share/applications/SQLDeveloper.desktop
Fill in the fields, using the fully qualified sqldeveloper.sh as the command and the "SQL Developer" as the application name, and close the window. (You should also set the icon too. There's one shipped with SQL Developer.) This is a handy tool for creating .desktop files. They are just simple text files that can also be created and edited using any text editor. Take a look in /usr/share/applications to see the full list of supplied ones.
Next, tell the desktop to read this new file so it's available in Dash:
Finally press the 'Super' key and type "sql". You should see the new SQL Developer application listed, and you should be able to drag it onto the Launcher. Click the new icon on the Launcher to test that it starts up SQL Developer.
So far so good. It works, but not quite correctly. The problem now is that when you use the Launcher to start SQL Developer it does startup correctly, but the new instance is not associated with the original Launcher icon. It should have a small arrow on the left edge of the icon, but that's missing, and instead it adds a new icon to the Launcher. This is really annoying if you have several Applications that work this way because you end up with 6 icons instead of 3!
The problem this time is the way the Launcher interacts with running X-windows programs to associate them with the launching icon. It uses a property from the running window called WM_CLASS(STRING). Use 'xprop' to dump the properties for any running application into a terminal window. For example, SQL Developer reports lots of properties, but specifically: WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "oracle-ide-boot-Launcher"
The solution is to add the following property the .desktop file you created earlier. Unfortunately, you'll need to edit the file with a text editor because the UI only allows a small sub-set of properties to be set:
sudo gedit /usr/share/applications/SQLDeveloper.desktop
And add a new property: StartupWMClass=oracle-ide-boot-Launcher
Don't forget to update the desktop's database of applications:
Now when you run SQL Developer it should behave exactly like other applications in Unity. Hooray!