openInstaller Feature Overview: Desktop Integration
By jayzspeak on Jun 02, 2007
Desktop integration is a term that collectively refers to the set of tasks that the install framework does to configure / unconfigure the install image. In the simplest of cases, it could mean the creation of a few shortcuts to the installed software's executable in the desktop and/or in the user's Start menu or Programs menu. However, in quite a few other cases, it could also mean tasks like starting / stopping a few services on system startup / shutdown and installing the application into the system tray (or notification area).
Desktop integration depends primarily on detecting the current environment that is installed on the target system. While Windows has its own unique desktop environment, UNIX-based operating systems like Solaris and Linux come with their own different flavors of desktop environments, the most famous of which are the GNOME and the KDE desktops. Currently openInstaller supports the following features on two desktop environments.
- GNOME – creation and removal of desktop & Launch menu / Applications shortcuts.
- Windows – creation and removal of desktop shortcuts, Start menu / Programs shortcuts & Add/Remove Programs entries.
THE GNOME IMPLEMENTATION
Creation of a shortcut in GNOME involves creation of a special kind of file called the .desktop file. The location where the .desktop file is installed or placed determines where the shortcut appears (in the user's desktop or Applications menu).
Structure of a .desktop file
A .desktop file looks very similar to a properties file whose first line is always [Desktop Entry] and has values defined for a few important keys like
Name - the name that appears in the shortcut.
Type - either of Application/Link/Directory.
Icon - the image file to be used as icon for the shortcut.
Exec - the executable to be run if this shortcut is clicked.
Shown below is a sample .desktop file.
Comment=A tool used for mathematical calculations.
Submenus & .directory files
In order to create shortcuts under custom submenus under the Applications menu, special files called .directory files need to be created. The structure of a .directory file is pretty much the same as a .desktop file, except that the value of the Type property is always “Directory” and the filename has a .directory extension.
Standard locations for .desktop & .directory files
The .desktop file that contains the shortcut information should be placed in the appropriate directories depending on whether it is a root or a user installation. The standard locations are given below.
|What / How||Root installation||User installation|
|Launch menu||/usr/share/applications||~/.gnome2/vfolders/applications (till GNOME 2.8) (or) ~/.local/share/applications (GNOME 2.10 & above)|
|.directory files||/usr/share/desktop-directories||~/.gnome2/vfolders/applications (till GNOME 2.8) (or) ~/.local/share/desktop-directories (GNOME 2.10 & above)|
Vfolders and .vfolder-info files
Start menu shortcuts creation in GNOME for user installations involves much more than simply installing a .desktop file in the appropriate folder. Every submenu under the applications menu is a virtual folder and hence any new submenu that should appear under the Applications menu should first be merged with the main Applications menu.
User installations can do this merging by adding suitable entries for the .desktop and .directory files, to an important file called applications.vfolder-info, which resides under ~/.gnome2/vfolders. It's basically an XML file that conforms to the vfolder-info DTD that is specified as part of Freedesktop standards.
Note: Vfolders is a standard that is deprecated since GNOME version 2.10.
Menus and .menu files
As of GNOME version 2.10 and above, custom submenus under the Applications menu can be created and merged with the main Applications menu by means of special files called .menu files. The standard location for placing these .menu files is /etc/xdg/menus/applications-merged for root user and ~/.config/menus/applications-merged for non-root user. A .menu file is a simple XML file that conforms to the menu specification DTD that is again specified as part of Freedesktop standards.
THE WINDOWS IMPLEMENTATION
Unlike GNOME, the creation of shortcuts in Windows is pretty simple and straightforward. All that needs to be done is to create a shortcut or a link in the appropriate folder by means of executing a creation or deletion script. The parameters required to create/remove the shortcut are used to create a VB Script file (.vbs), which is then executed in the user's environment using the Windows Script Host (WSH) framework. The “cscript” command of the Windows Script Host is being used for this purpose.
Given below is an example script that creates a shortcut on all users' desktop.
Dim WSHShell, LinkFile
Set WSHShell = Wscript.CreateObject("WScript.Shell"
LinkFile = “C:\\Documents and Settings\\All Users\\Desktop\\Java Homepage.url”
Set Link = WSHShell.CreateShortcut(LinkFile)
Link.TargetPath = “http://java.sun.com”