May 25, 2011

Configure Default Applications For GNOME And KDE on Linux

Linux comes with lots of applications that can handle URLs, sending emails, viewing pictures, playing music, and more. The question is, what application does your desktop environment launch by default when you try to open an MP3, send an email, or visit a URL? If it's not the application you prefer, it's time to configure the desktop to default to your favorite app. Not sure how? Let's take a look at setting default applications in Linux under GNOME and KDE.

GNOME and KDE allow users to set specific applications for specific actions (called Default Applications). In both cases, the Default Applications can be configured by the user, such that the user can make just about any installed application the default. Just how is this done in both GNOME and KDE? Let's dig in and answer that question.

GNOME Default Applications

The current state of GNOME is in a bit of flux. I say that because there are three different major versions of GNOME being used:

  • Classic GNOME: This is the GNOME the Linux community has grown to know and love.
  • GNOME with Unity as its shell: This is the now default desktop for the Ubuntu distribution that offers an entirely different user experience. Unity is based on GNOME 2; but will, at some point, migrate to the GNOME 3 libraries.
  • GNOME 3 with GNOME Shell: This is the newest iteration of GNOME that, like Unity, offers an entirely different user experience.

Each of the versions use the same tool to configure the default applications, the only difference is in getting to the application used to make the changes — at least from within the different menu structures. Fortunately, the command to start the tool has not changed. In order to start the Preferred (Default) Applications tool do the following:

  1. Hit the Alt-F2 combination.
  2. Enter the command gnome-default-applications-properties and hit the Enter key.

What about from the desktop menu? Since Ubuntu Unity is the new default for the Ubuntu Linux distribution, let's illustrate opening the Preferred Applications tool there. In order to start the application from the Unity desktop do the following:

  1. Click the Applications icon in the launcher.
  2. From the Applications drop-down (upper right corner), select Themes & Tweaks.
  3. From the Installed section, click the Show More Results link (see Figure 1).
  4. Scroll down and click the Preferred Applications.

Figure 1It's also possible to enter "default" in the search bar to bring up the Preferred Applications launcher.

Once the Preferred Applications tool is open, it's time to get to work. GNOME has made this task incredibly simple. There really aren't any tricks to the task, simply select the installed application from the drop-down associated with the application type necessary. For example, in order to configure Chromium as the default Web browser, select Chromium Web Browser from the Web Browser drop-down. In the case of the Web Browser, Email Client, and accessibility options the only choices are made from the drop-downs. For the default multimedia player (in the Multimedia drop-down) it is possible to select a custom application. To do this select Custom from the drop-down and then enter the command to be run in the Command text area (see Figure 2).

Make sure the command is formatted correctly (such as "vlc %U".)

Figure 2It is important to note that, when configuring a custom application for multimedia, there are instances where the command must be run in a terminal window. This must be used for a tool that does not, on its own, create an application window in which to run. Typically, this means non-GUI applications such as play and mplayer.

File Manager Defaults

There is one other location that default applications can be configured. Open up the Nautilus File Manager and click Edit > Preferences. In this new window click on the Media tab to reveal a list of Media Handling options. Here the defaults for the following can be configured by simply selecting the option from a drop-down.

  • CD Audio
  • DVD Video
  • Music Player
  • Photos
  • Software
  • DVD Audio

By default, all of the above (minus Software) will be set to "Ask Me". These actions are for when media (such as a CD or flash drive) is inserted that contains media files (such as music). Nautilus can also be set to not take action by simply checking the box associated with "Never prompt or start programs on media insertion."

KDE Default Applications

Because there is only one version of KDE, things get a bit more simplistic. The Default Applications for KDE are handled similarly to that of GNOME. To get to the settings click K Menu > Computer > System Settings. When the System Settings window opens click on the Default Applications icon. In this new window (see Figure 3) the majority of the Default Applications can be chosen. Unlike GNOME, KDE allows the custom configuration of most of the entries (instead of limiting the entries to a drop-down of installed applications).

Figure 3There are two entries (Embedded Text Editor and Instant Messenger) that can only be chosen via drop-down.

Each of the KDE Default Applications will offer the equivalent KDE application as the default (such as KMail for email, Konqueror for Web browsing, Dolphin for file management). That does not mean GNOME-based applications (or desktop-neutral applications) can not be chosen. I would highly recommend not changing the default window manager as that could quickly break the KDE desktop which might then only be reparable from within the command line.

Just for clarification, the Embedded Text editor is the text editor that other applications (such as KMail and Kate) use. At the moment, this can not be changed (Much to the chagrin of some die hard users who prefer alternate vi or emacs key bindings) as too many applications require the KDE Advanced Text Editor in order to function.

As far as file manager settings, there are no Default Applications that can be configured within Dolphin. In order handle default applications for inserted media hop on over to the Device Actions section under the Hardware portion of the System Settings window. Here any number of default actions and applications can be configured for various media types.

By default there are numerous actions already created (see Figure 4). These actions can either be edited or new actions can be created. Look through the default list to find the action to be configured.Figure 4
There is already an action created for the insertion of audio CDs.

Say, for example, the insertion of an audio CD should automatically bring up the VLC media player. Since an action already exists for this, what is needed is to edit the existing action that opens Amarok. Select this action, click Edit, and change the Command section to reflect the change from Amarok to VLC. For this action, you have a few more configuration options to deal with:

  • Command: The command to run the application, including the parameters necessary to run the command with the media. For VLC use vlc cdda://.
  • Parameter Type: This should remain the default (Property Match).
  • Device Type: Since this action is for audio Discs, the type will be Optical Disc.
  • Value Name: This relates to what is on the disc and/or the type of disk (rewritable, blank, FS type, etc.) For audio discs, the option should be Available Content.
  • Contains: This should be set to Audio.

Once the above is configured, click Save Parameter Changes, and click OK. Now, to make sure KDE is aware of these changes, log out and log back in. When an audio disc is inserted the VLC player should open, instead of Amarok.

Defaults Make Life Simple

In order for a desktop, even a desktop like Unity, to be truly efficient, default applications need to be set. If these defaults are not configured every time a url or mailto link is clicked the right application may or may not open, causing a bottle neck in the work flow of the user. In order to make this process as user-friendly as possible, the setting of Default Applications is necessary.