dilluns, 2 de juny del 2008

Configurant aplicacions al menú Ubuntu

Si mai afegim una aplicació fora del curs reglamentari d'apt-get install, ens trobarem que no la tindrem disponible al menú Aplicacions d'Ubuntu.

Per a crear-ne una, en aquest cas l'Eclipse que hem instal·lat a /opt/eclipse, farem el següent des de root:
vi /usr/share/applications/eclipse.desktop
I afegirem aquesta informació
[Desktop Entry]
Name=Eclipse
Comment=Entorn de desenvolupament per a molts llenguatges de programació.
Exec=/opt/eclipse/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=Development;
StartupNotify=true

En aquesta taula veurem una breu explicació del que vol dir cada paràmetre, i en aquest lloc trobarem la definició de l'estandard Desktop Entry Specification 1.0.
KeyDescriptionValue TypeREQ?Type
Type This specification defines 3 types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3). To allow the addition of new types in the future, implementations should ignore desktop entries with an unknown type. stringYES
Version Version of the Desktop Entry Specification that the desktop entry conforms with. Entries that confirm with this version of the specification should use 1.0. Note that the version field is not required to be present. numericNO1-3
Name Specific name of the application, for example "Mozilla". localestringYES1-3
GenericName Generic name of the application, for example "Web Browser". localestringNO1-3
NoDisplay NoDisplay means "this application exists, but don't display it in the menus". This can be useful to e.g. associate this application with MIME types, so that it gets launched from a file manager (or other apps), without having a menu entry for it (there are tons of good reasons for this, including e.g. the netscape -remote, or kfmclient openURL kind of stuff). booleanNO1-3
Comment Tooltip for the entry, for example "View sites on the Internet", should not be redundant with Name or GenericName. localestringNO1-3
Icon Icon to display in file manager, menus, etc. If the name is an absolute path, the given file will be used. If the name is not an absolute path, the algorithm described in the Icon Theme Specification will be used to locate the icon. localestringNO1-3
Hidden Hidden should have been called Deleted. It means the user deleted (at his level) something that was present (at an upper level, e.g. in the system dirs). It's strictly equivalent to the .desktop file not existing at all, as far as that user is concerned. This can also be used to "uninstall" existing files (e.g. due to a renaming) - by letting make install install a file with Hidden=true in it. booleanNO1-3
OnlyShowIn, NotShowIn A list of strings identifying the environments that should display/not display a given desktop entry. Only one of these keys, either OnlyShowIn or NotShowIn, may appear in a group (for possible values see the Desktop Menu Specification). string(s)NO1-3
TryExec File name of a binary on disk used to determine if the program is actually installed. If not, entry may not show in menus, etc. stringNO1
Exec Program to execute, possibly with arguments. stringNO1
Path If entry is of type Application, the working directory to run the program in. stringNO1
Terminal Whether the program runs in a terminal window. booleanNO1
MimeType The MIME type(s) supported by this application. string(s)NO1
Categories Categories in which the entry should be shown in a menu (for possible values see the Desktop Menu Specification). string(s)NO1
StartupNotify If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_LAUNCH_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all (does not shown any window, breaks even when using StartupWMClass, etc.). If absent, a reasonable handling is up to implementations (assuming false, using StartupWMClass, etc.). (See the Startup Notification Protocol Specification for more details). booleanNO1
StartupWMClass If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the Startup Notification Protocol Specification for more details). stringNO1
URL If entry is Link type, the URL to access. stringNO2