How To Configure the KDE 3.3 Menu manually (without KMenuEdit)
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
By MasterPatricko at 2004-11-15 16:42
You can muck up your entire menu if you make any mistakes editing these files. Unless you are comfortable with editing lots of text files by hand, don't try this. Then again, most, if not all, errors should be fixable.
The file locations:
On SuSE 9.1 and KDE 3.3 (They may be in different places on other distributions):
Main file (.menu file) detailing system-wide default menu structure is /etc/xdg/menus/applications.menu
Menu directories (.directory files) are stored in /usr/share/desktop-directories/
System-wide Menu entries (.desktop files) are stored in many places.
Gnome applications: /opt/gnome/share/applications
KDE applications: /opt/kde3/share/applications/kde
Other Applications: /usr/share/applications
(~ means the home directory of the user - e.g. /home/bubbabob if you are bubbabob)
User-specific applications (.desktop files) are in ~/.local/share/applications
User-specific menu edits (.menu file) are in ~/.config/menus/
If they are not there just search for .desktop / .directory / .menu files on your system and you should be able to find the right folder(s).
Explanation of the Files involved:
.menu files decide the structure of the menu by categorizing .desktop entries into directories. They are based on the Desktop Menu Specification by freedesktop.org. The dtd and specifications sheets can be seen at http://freedesktop.org/Standards/menu-spec.
.directory files are the files that represent the directories that applications are organized into. Really they are only used to assign an icon (picture) to the directory. They are also part of the Desktop Entry Specification.
First of all what is a directory, a menu and an application shortcut.
The main menu that opens up when you click the "K" (or whatever you have in your distro - eg. SuSE has its logo) is the main menu.
The sub-menus are actually .directory files. There can be many menus nested in each other, but each menu or sub-menu or sub-sub-menu is actually a separate .directory file in the desktop-directories folder, eg. 'System --> Terminal' is actually /usr/share/desktop-directories/suse-system-terminal.directory on my computer.
The items that you click to open the application are application shortcuts. They are .desktop files, e.g. Menu --> System Sub-Menu --> Terminal Sub-Menu --> "X Terminal" is actually /usr/share/applications/xterm.desktop which starts up 'xterm'.
Note that you need root permissions to properly create and edit files in any of the system-wide directories. An easy, graphical way to navigate with root permissions with KDE is to use "Konqueror - Super User Mode" - the shortcut to it should be under "System" in your Menu.
To edit the files all you need is a simple text editor.
A way to start the graphical ones with root permissions in KDE:
1. Menu --> Run Command (or Alt-F2)
2. Type in "xedit" or "kate" or whatever program you want to run in the "Command" box.
3. Click "Options". Check "Run as a different User". Type in "root" as the user and your root password as the password.
4. Press "Run".
The editor should open up. Use their "File --> Open" or "Load" to open the file you want to edit.
To add an application to the menu:
Create the .desktop file for it in /usr/share/applications if you want it for all users or ~/.local/share/applications if you want it for only one user. Or you can just copy an existing one, rename it, and change it to what you need.
Open this file in your text editor. Here is a sample .desktop file I created for Mozilla Firefox, in a file called firefox.desktop in /usr/share/applications:
And now an explanation of what all the parts are:
Encoding=UTF-8 this will probably UTF-8; use whatever encoding you are using on the rest of your machine.
Type=Application tells the system this is an application. The other type is Type=Directory, which you'll see later.
Exec=/usr/local/firefox tells the command to execute. Its always best to include the full path of the executable (e.g. /bin/chmod , not just chmod ) to prevent any mistakes of the folder not being in $PATH, etc.
Icon=firefox tells the system to use the "firefox" icon which is installed on my system. Default Icons are in /opt/kde3/share/icons/.
Name=Firefox tells the specific name of the program.
GenericName=Web Browser is usually used to show the type of program it is. E.g. 'konsole' has a GenericName=Terminal Program
Categories=Network;X-SuSE-WebBrowser;WebBrowser; Categories are separated by semicolons with no spaces. Be careful not to make spelling mistakes! This is the hard one.
To find out what category to use, Look in your applications.menu file to see the various menus and submenus - see what category the menu you want your application to be in requires.
This is the section of my applications.menu that makes the "Network --> Web Browser" menu. As you can see in the <Category> tags, if I want my new shortcut to be in the "Web Browser" menu, it has to have "WebBrowser" as one of its categories. I check on the menu specification and find Network is related to Web Browser. So my sample 'Mozilla Firefox' shortcut has to have categories "Network;WebBrowser" and will be in this menu.
To remove an item from the menu, there are two ways. One is to just move or delete the application's .desktop file. The other is to use:
in your application.menu in the right place to remove foo.desktop from the menu. More later.
To move an item from one sub-menu to another, first look in your applications.menu and find out what category it has to have. Then open the desktop file and change the "Category=" to what you want. Include any new related categories. Remember to remove the old categories or it will be in both menus!
To create a sub-menu/menu:
First create a .directory file, just like a .desktop file. Here is a sample one. They are even simpler.
The <Menu> tags start and end the menu. <DontShowIfEmpty/> means if there are no .desktop files that have that category this menu will not be displayed. <Directory> specifies the .directory file to use to get the name and icon. <Name> actually does NOT change the displayed name - the name of the .directory file overrides it. <Include> specifies what categories to include in the menu. You can use <And> to make it have two categories or <Or> to make it have either. You can also use <Not> to not include certain categories. Use <Filename>foo.desktop</Filename> to include just foo.desktop in the menu. There is also another way to stop things from getting in the menu: <Exclude>. It works just like <Include>, using and, or, & not. Nest this section inside the menu you want it in, like the following example which also shows and, not and exclude:
In that example the first </Menu> ends the Font Viewer menu and the second </Menu> ends the Graphics menu, so the Font Viewer menu is nested inside Graphics. To be in the menu a .desktop file has to have categories of both FontViewer and Graphics. It cannot have, however, a category of Office. Other modifications to the menus can be made in the same way, modifying the applications.menu file. For more info on the tags available look at the Menu-Specification sheet.
To remove a sub-menu just comment out using <!-- and --> in case you need it again or just delete its section. Be sure to remove only that menu's section and not part of its parent menu!
I'm currently working on understanding the user-specific .menu files produced by KMenuEdit (which are an absolute mess) and seeing how I can simplify it so a user can write it by hand.
KDE Menus are configured in .desktop, .directory, and .menu files. The .directory files are the menus and sub-menus; the .desktop files are the application shortcuts. The .menu file categorizes the .desktop files into the various directories. To add an application, add a .desktop file; to add a directory, create a .directory file and modify the applications.menu file. Other changes must generally be made in the applications.menu file.