Development/Howto/MenuMigrationToXDG
From Mandriva Community Wiki
Starting with Mandriva Linux 2007, old Debian Menu System is deprecated and replaced by the XDG Menu System.
Contents |
[edit] Migration plan
Migration to XDG Menu System will be done in several phases :
- preliminar phase : use XDG code in desktop environments supporting it already :
- Debian menu system should be able to generate XDG compliant menu with a specific menu-method DONE in Mandriva Linux 2005LE
- all window manager / desktop environment able to support XDG menu system (KDE, GNOME) should use XDG menu generated by Debian menu system DONE in Mandriva Linux 2005 LE
- ship a generic .menu file containing the current menu hierachy and use this file instead of the generated .menu file from Debian menu system. This file should use .desktop files from /usr/share/applications in addition to generated .desktop files from Debian Menu System. DONE in cooker
- for all packages shipping with .desktop (GNOME / KDE) : in progress
- add a new keyword in old menu file "xdg=true", forcing XDG menu-method to NOT generate .desktop for those files
- use upstream .desktop file, modified with desktop-file-install to add missings categories or mime-type.
- for window managers not supporting XDG menu system, write scripts to convert XDG menu to window-manager specific config files. Use SUSE xdg-menu script as a basis, which already support WindowMaker, icewm, xfce4, fvwm2, blackbox, fluxbox, openbox, openbox3, openbox3-pipe. All modifications to this script should be sent upstream to SUSE maintainer. DONE in cooker
- create .desktop files for all packages which weren't shipping with .desktop file already in progress
- patch back GNOME / KDE to use upstream menu editor instead of menudrake and to load translations for menu entries from menu-messages.mo file when not available in .desktop file
- kill menudrake and debian menu system.
- Replace update-menus by a generic program which will update configuration files using xdg-menu script. DONE in cooker
- for packages which are not backported, remove old debian menu file from the packages.
[edit] Migration example
Please read XDGMenuSystem carefully, as it explains the new system in details.
[edit] package with no .desktop file and no mimetypes
based on skobo specfile, here is the full diff to switch to XDG (keeping compatibility):
--- skobo.spec.old 2006-07-07 12:13:29.000000000 +0200 +++ skobo.spec 2006-07-07 11:23:41.000000000 +0200 @@ -2,7 +2,7 @@ Name: skobo Version: 0.4 %define pre pre10 -%define release %mkrel 0.%{pre}.6 +%define release %mkrel 0.%{pre}.7 Release: %{release} License: GPL Group: Games/Arcade @@ -48,9 +48,24 @@ title="Kobo Deluxe"\ longtitle="Arcade video game"\ command="%_gamesbindir/kobodl"\ - icon="%name.png" + icon="%name.png"\ + xdg="true" EOF +mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications +cat > $RPM_BUILD_ROOT%{_datadir}/applications/mandriva-%{name}.desktop << EOF +[Desktop Entry] +Encoding=UTF-8 +Name=Kobo Deluxe +Comment=Arcade video game +Exec=%_gamesbindir/kobodl +Icon=%{name} +Terminal=false +Type=Application +Categories=Game;ArcadeGame;X-MandrivaLinux-MoreApplications-Games-Arcade; +EOF + + install -D -m644 %SOURCE6 $RPM_BUILD_ROOT%{_iconsdir}/%{name}.png install -D -m644 %SOURCE5 $RPM_BUILD_ROOT%{_miconsdir}/%{name}.png install -D -m644 %SOURCE7 $RPM_BUILD_ROOT%{_liconsdir}/%{name}.png @@ -71,12 +86,16 @@ %attr(775, root, games) %{_localstatedir}/games/%{name} %{_gamesdatadir}/* %{_mandir}/man6/* +%{_datadir}/applications/* %{_menudir}/* %{_iconsdir}/*.png %{_miconsdir}/* %{_liconsdir}/* %changelog +* Fri Jul 7 2006 Pixel <[email protected]> 0.4-0.pre10.7mdv2007.0 +- switch to XDG menu + * Fri May 26 2006 Pixel <[email protected]> 0.4-0.pre10.6mdv2007.0 - use std mkrel
[edit] package already shipping .desktop file
based on xchat specfile, which was already shipping with .desktop file :
in %install, there was the following text :
cat > $RPM_BUILD_ROOT%{_menudir}/%{name} << EOF ?package(%name): needs="x11" \ section="Internet/Chat" \ title="Xchat" \ longtitle="%{main_summary}" \ command="%{_bindir}/%{name}" \ icon="%{name}.png" \ EOF
after migration, there should be :
cat > %{buildroot}%{_menudir}/%{name} << EOF ?package(%name): needs="x11" \ section="Internet/Chat" \ title="Xchat" \ longtitle="%{main_summary}" \ command="%{_bindir}/%{name}" \ icon="%{name}.png" \ xdg="true" EOF desktop-file-install --vendor="" \ --remove-category="Application" \ --add-category="GTK" \ --add-category="IRCClient" \ --add-category="X-MandrivaLinux-Internet-Chat" \ --dir $RPM_BUILD_ROOT%{_datadir}/applications $RPM_BUILD_ROOT%{_datadir}/applications/*
[edit] package not shipping desktop file
Before migration, the following text could be found :
cat > $RPM_BUILD_ROOT%{_menudir}/%{name} << EOF ?package(%name): needs="x11" \ section="Multimedia/Video" \ title="Totem" \ longtitle="%{main_summary}" \ command="%{_bindir}/%{name}" \ icon="%{name}.png" \ mimetypes="application/x-extension-mp4,application/x-extension-m4a" \ startup_notify="true" \ accept_url="true" \ multiple_files="true" EOF
after migration :
cat > $RPM_BUILD_ROOT%{_menudir}/%{name} << EOF ?package(%name): needs="x11" \ section="Multimedia/Video" \ title="Totem" \ longtitle="%{Summary}" \ command="%{_bindir}/%{name}" \ icon="%{name}.png" \ mimetypes="application/x-extension-mp4,application/x-extension-m4a" \ startup_notify="true" \ accept_url="true" \ multiple_files="true" \ xdg="true" EOF ps: everything here get's written to the file, even though commented with #, please be aware of this and strip out mkdir -p %{buildroot}%{_datadir}/applications cat > %{buildroot}%{_datadir}/applications/mandriva-%{name}.desktop << EOF [Desktop Entry] Name=Totem # %{Summary} needs to be defined first, DON'T USE %{summary} as it gets redefined by sub packages (like -debug) Comment=%{Summary} Exec=%{_bindir}/%{name} %U # (in this example, %U is there because accept_url=true and multiple_files=true) # Exec=%{''bindir}/%{name} if accept''url=false AND multiples_files=false, see http://qa.mandriva.com/twiki/bin/view/Main/XDGMenuSystem for complete details # (no filename extension for icon, it is guessed automatically) Icon=%{name} # if needs=text, set to true Terminal=false Type=Application Categories=GNOME;GTK;AudioVideo;Audio;Video;Player;X-MandrivaLinux-Multimedia-Video; (see Categories section below) #### the following lines are optional MimeType=application/x-extension-mp4;application/x-extension-m4a; (if mimetypes were specified in the menu file) StartupNotify=true (if present is menu file) Encoding=UTF-8 EOF
As a sidenote, you may notice desktop-file-install is not used in this case, because it is only used to modify exiting file (in our example). This utility might be used by ISV but for Mandriva packages and since .desktop files are written from scratch in this particular case, it would be overkill.
Packages which are supposed to be backportable should continue to ship old debian menu entries in /usr/lib/menu.
You may want to check .desktop file with desktop-file-validate program.
[edit] Mime types
association between an application and a mime-type is done in .desktop file. If a Mimetype key is present in a .desktop file, %{update_desktop_database} and =%{clean_desktop_database}= macro should be added to %post / %postun as explained here.
[edit] Translations
Translations for this file will be managed using po file in mdk-menu-message CVS module.
[edit] Categories
Categories need to be added, both using compatibility categories keys for old Mandriva system as listed here and with registered categories from the official specification, as listen here.
The following list give the new categories to add whenever the previous section was used for a menu entry :
Old Category | New Category |
---|---|
Office/Accessories | X-MandrivaLinux-Office-Accessories;Office;Utility/ Calculator/ Dictionary / Clock?; |
Office/Address Books | X-MandrivaLinux-Office-AddressBooks;Office;ContactManagement; |
Office/Communications/Fax | X-MandrivaLinux-Office-Communications-Fax; |
Office/Communications/PDA | X-MandrivaLinux-Office-Communications-PDA;Office;PDA; |
Office/Communications/Phone | X-MandrivaLinux-Office-Communications-Phone;Network;Telephony ?; |
Office/Drawing | X-MandrivaLinux-Office-Drawing;Graphics;2DGraphics / VectorGraphics / RasterGraphics ?; |
Office/Graphs | X-MandrivaLinux-Office-Graphs;Office;Chart / FlowChart ?; |
Office/Presentations | X-MandrivaLinux-Office-Presentations;Office;Presentation; |
Office/Publishing | X-MandrivaLinux-Office-Publishing;Graphics;Scanning / OCR / Office;Viewer; |
Office/Spreadsheets | X-MandrivaLinux-Office-Spreadsheets;Office;Spreadsheet; |
Office/Tasks Management | X-MandrivaLinux-Office-TasksManagement;Office;ProjectManagement ?; |
Office/Time Management | X-MandrivaLinux-Office-TimeManagement;Office;Calendar; |
Office/Wordprocessors | X-MandrivaLinux-Office-Wordprocessors;Office;WordProcessor; |
Internet/Chat | X-MandrivaLinux-Internet-Chat;Network;IRCClient; |
Internet/File Transfer | X-MandrivaLinux-Internet-FileTransfer;Network;FileTransfer;P2P; |
Internet/Instant Messaging | X-MandrivaLinux-Internet-InstantMessaging;Network;InstantMessaging; |
Internet/Mail | X-MandrivaLinux-Internet-Mail;Office;Network;Email; |
Internet/News | X-MandrivaLinux-Internet-News;Network;News; |
Internet/Other | X-MandrivaLinux-Internet-Other;Network / HamRadio?; |
Internet/Remote Access | X-MandrivaLinux-Internet-RemoteAccess;Network;RemoteAccess; Dialup; |
Internet/Video Conference | X-MandrivaLinux-Internet-VideoConference;Network;Telephony ?; |
Internet/Web Browsers | X-MandrivaLinux-Internet-WebBrowsers;Network;WebBrowser; |
Internet/Web Editors | X-MandrivaLinux-Internet-WebEditors;Network;WebDevelopment; |
Multimedia/Graphics | X-MandrivaLinux-Multimedia-Graphics;Graphics / Photography / 3DGraphics ; Graphics;Viewer; |
Multimedia/Sound | X-MandrivaLinux-Multimedia-Sound;AudioVideo;Audio / Midi / Mixer / Sequencer / Tuner / Audio;AudioVideoEditing / Audio;Player / Audio;Recorder; |
Multimedia/Video | X-MandrivaLinux-Multimedia-Video;AudioVideo;Video / TV / Video;AudioVideoEditing / Video;Player / Video;Recorder; |
System/Archiving/Backup | X-MandrivaLinux-System-Archiving-Backup;Archiving;Utility; |
System/Archiving/CD Burning | X-MandrivaLinux-System-Archiving-CDBurning;Utility;DiscBurning; |
System/Archiving/Compression | X-MandrivaLinux-System-Archiving-Compression;Archiving;Utility; |
System/Archiving/Other | X-MandrivaLinux-System-Archiving-Other;Archiving;Utility; |
System/Configuration/KDE | X-MandrivaLinux-System-Configuration-KDE;Settings;DesktopSettings;KDE; |
System/Configuration/GNOME | X-MandrivaLinux-System-Configuration-GNOME;Settings;DesktopSettings;GNOME; |
System/Configuration/GNOME/Advanced | X-MandrivaLinux-System-Configuration-GNOME-Advanced;Settings;DesktopSettings;GNOME; |
System/Configuration/GNOME/Accessibility | X-MandrivaLinux-System-Configuration-GNOME-Accessibility;Settings;DesktopSettings;GNOME; |
System/Configuration/Boot and Init | X-MandrivaLinux-System-Configuration-BootandInit;System; |
System/Configuration/Hardware | X-MandrivaLinux-System-Configuration-Hardware;Settings;HardwareSettings; |
System/Configuration/Networking | X-MandrivaLinux-System-Configuration-Networking;Settings;Network; |
System/Configuration/Other | X-MandrivaLinux-System-Configuration-Other;Settings; |
System/Configuration/Packaging | X-MandrivaLinux-System-Configuration-Packaging;Settings;PackageManager; |
System/Configuration/Printing | X-MandrivaLinux-System-Configuration-Printing;Settings;HardwareSettings ?; |
System/File Tools | X-MandrivaLinux-System-FileTools;System;Filesystem / FileManager ?; |
System/Monitoring | X-MandrivaLinux-System-Monitoring;System;Monitor; |
System/Session/Windowmanagers | X-MandrivaLinux-System-Session-Windowmanagers; |
System/Terminals | X-MandrivaLinux-System-Terminals;TerminalEmulator; |
System/Text Tools | X-MandrivaLinux-System-TextTools; |
More Applications/Accessibility | X-MandrivaLinux-MoreApplications-Accessibility;Utility;Accessibility; |
More Applications/Communications | X-MandrivaLinux-MoreApplications-Communications;?; |
More Applications/Databases | X-MandrivaLinux-MoreApplications-Databases;Database;(Office / Development / AudioVideo); |
More Applications/Development/Code Generators | X-MandrivaLinux-MoreApplications-Development-CodeGenerators;Development;Building; |
More Applications/Development/Development Environments | X-MandrivaLinux-MoreApplications-Development-DevelopmentEnvironments;Development;IDE / GUIDesigner; |
More Applications/Development/Interpreters | X-MandrivaLinux-MoreApplications-Development-Interpreters;Development; |
More Applications/Development/Tools | X-MandrivaLinux-MoreApplications-Development-Tools;Development;Debugger / Profiling / RevisionControl / Translation; |
More Applications/Documentation | X-MandrivaLinux-MoreApplications-Documentation;?; |
More Applications/Editors | X-MandrivaLinux-MoreApplications-Editors;TextEditor; |
More Applications/Emulators | X-MandrivaLinux-MoreApplications-Emulators;Emulator; |
More Applications/Finances | X-MandrivaLinux-MoreApplications-Finances;Office;Finance; |
More Applications/Games/Adventure | X-MandrivaLinux-MoreApplications-Games-Adventure;Game;AdventureGame; |
More Applications/Games/Arcade | X-MandrivaLinux-MoreApplications-Games-Arcade;Game;ArcadeGame; |
More Applications/Games/Boards | X-MandrivaLinux-MoreApplications-Games-Boards;Game;BoardGame; |
More Applications/Games/Cards | X-MandrivaLinux-MoreApplications-Games-Cards;Game;CardGame; |
More Applications/Games/Other | X-MandrivaLinux-MoreApplications-Games-Other;Game / ActionGame? / KidsGame / RolePlaying / Simulation ; |
More Applications/Games/Puzzles | X-MandrivaLinux-MoreApplications-Games-Puzzles;Game;LogicGame / Game;BlocksGame; |
More Applications/Games/Sports | X-MandrivaLinux-MoreApplications-Games-Sports;Game;SportsGame; |
More Applications/Games/Strategy | X-MandrivaLinux-MoreApplications-Games-Strategy;Game;StrategyGame; |
More Applications/Games/Toys | X-MandrivaLinux-MoreApplications-Games-Toys;Amusement; |
More Applications/Sciences/Artificial Intelligence | X-MandrivaLinux-MoreApplications-Sciences-ArtificialIntelligence; |
More Applications/Sciences/Astronomy | X-MandrivaLinux-MoreApplications-Sciences-Astronomy;Science;Astronomy; |
More Applications/Sciences/Biology | X-MandrivaLinux-MoreApplications-Sciences-Biology;Science;Biology; |
More Applications/Sciences/Chemistry | X-MandrivaLinux-MoreApplications-Sciences-Chemistry;Science;Chemistry; |
More Applications/Sciences/Computer Science | X-MandrivaLinux-MoreApplications-Sciences-ComputerScience; |
More Applications/Sciences/Data Visualization | X-MandrivaLinux-MoreApplications-Sciences-DataVisualization; |
More Applications/Sciences/Electricity | X-MandrivaLinux-MoreApplications-Sciences-Electricity;Science ? / Electronics; |
More Applications/Sciences/Geosciences | X-MandrivaLinux-MoreApplications-Sciences-Geosciences;Science;Geology ?; |
More Applications/Sciences/Image Processing | X-MandrivaLinux-MoreApplications-Sciences-ImageProcessing; |
More Applications/Sciences/Mathematics | X-MandrivaLinux-MoreApplications-Sciences-Mathematics;Science;Math; |
More Applications/Sciences/Numerical Analysis | X-MandrivaLinux-MoreApplications-Sciences-NumericalAnalysis;?; |
More Applications/Sciences/Other | X-MandrivaLinux-MoreApplications-Sciences-Other;Science / Science;MedicalSoftware? / Engineering; |
More Applications/Sciences/Parallel Computing | X-MandrivaLinux-MoreApplications-Sciences-ParallelComputing;Science ?; |
More Applications/Sciences/Physics | X-MandrivaLinux-MoreApplications-Sciences-Physics;Science;Physics; |
More Applications/Sciences/Robotics | X-MandrivaLinux-MoreApplications-Sciences-Robotics;Science ?; |
More Applications/Shells | X-MandrivaLinux-MoreApplications-Shells;Shell; |
More Applications/Education | X-MandrivaLinux-MoreApplications-Education;Education; |
More Applications/Education/Economy | X-MandrivaLinux-MoreApplications-Education-Economy;?; |
More Applications/Education/Geography | X-MandrivaLinux-MoreApplications-Education-Geography;?; |
More Applications/Education/History | X-MandrivaLinux-MoreApplications-Education-History;?; |
More Applications/Education/Languages | X-MandrivaLinux-MoreApplications-Education-Languages;Education;Languages; |
More Applications/Education/Literature | X-MandrivaLinux-MoreApplications-Education-Literature;?; |
More Applications/Education/Sciences | X-MandrivaLinux-MoreApplications-Education-Sciences;Education;Science; |
More Applications/Education/Sports | X-MandrivaLinux-MoreApplications-Education-Sports;?; |
More Applications/Education/Other | X-MandrivaLinux-MoreApplications-Education-Other;Art / Construction / Music / Teaching; |
Some registered categories are not mapped to the old hierarchy :
Screensaver Applet TrayIcon Security
In the previous list, no registered categories were relevant enough in the official list. They might require approval to get new keys registered upstream :
Office/Communications/Fax Office/Communications/Phone ? System/Session/Windowmanagers ?? System/Text Tools More Applications/Documentation More Applications/Communications More Applications/Education/Economy More Applications/Education/Geography More Applications/Education/History More Applications/Education/Literature More Applications/Education/Sports More Applications/Sciences/Artificial Intelligence More Applications/Sciences/Computer Science More Applications/Sciences/Data Visualization More Applications/Sciences/Electricity More Applications/Sciences/Geosciences More Applications/Sciences/Image Processing More Applications/Sciences/Numerical Analysis More Applications/Sciences/Parallel Computing System/Configuration/Printing ? System/Archiving/Compression => Archiving ?
[edit] Support for older window managers
Window managers not supporting XDG menu system need to provide a compatibility script which can read XDG menu system and write native window manager configuration file.
Fortunately, SUSE hackers wrote a somehow generic perl script called xdg_menu which is able to output configuration files for the following window managers : WindowMaker, fvwm2, icewm, blackbox, fluxbox, openbox, xfce4, openbox3. To get those scripts started when new menu entries are added in the system, each window manager should ship a executable script named /etc/menu.d/<window_manager_name> which can call xdg_menu (or any other scripts). This script should support two environment variables : USER_MENU (set to 1 when generating user menu, set to 0 when generating system menu) and =VERBOSE= (set to 1 when running in debug mode).
Example of such script for icewm :
#!/bin/sh if [ "$USER_MENU" = "1" ]; then OUTPUTDIR=$HOME/.icewm else OUTPUTDIR=/usr/X11R6/lib/X11/icewm/ fi echo "prog \"Terminal\" /usr/share/icons/mini/terminals_section.png /usr/X11R6/bin/xvt -bg black -fg grey" > $OUTPUTDIR/menu if [ "$VERBOSE" = "1" ]; then echo "writing to $OUTPUTDIR/menu" /usr/bin/xdg_menu --verbose --format icewm >> $OUTPUTDIR/menu else /usr/bin/xdg_menu --format icewm > $OUTPUTDIR/menu 2>> /dev/null fi