Author Topic: HowTo: Customize your main menu  (Read 13357 times)

0 Members and 1 Guest are viewing this topic.

Offline trulan

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 910
  • Karma: +1/-0
HowTo: Customize your main menu
« on: September 17, 2011, 07:37:28 PM »
For its desktop environment, AVLinux uses LXDE.  It is easy on system resources, and very customizable.  Unfortunately, this customization can sometimes require a bit of hackery, and documentation tends to be sparse.  Case in point, the main menu:
http://wiki.lxde.org/en/Main_Menu

Now, GMaq has customized the menu quite a bit for AVLinux, which is great.  But, I wanted to do things my way, (and hey, this is Linux, so I should have the right to do that, correct?)  So, for anybody who wants the menu "their way" (or my way, because my way is of course the best one - jk), here's some helpful things to know:

1. Forget the menu editors:
Or try them for yourself, but I've had little to no success with alacarte, lxmed, and every other menu editor I tried.  YMMV.

2. The LXDE main menu is generated from three parts:
A. Launchers (.desktop files)
Most .desktop files are located in /usr/share/applications/.  Additionally, some launchers may be in /usr/local/share/applications.  These are system-wide.  .desktop files in ~/.local/share/applications/ are user-specific launchers.

B. Directories (.directory files)
These are in /usr/share/desktop-directories/, /usr/local/share/desktop-directories/, and ~/.local/share/desktop-directories (for user-specific menus).

C.  The menu file
This is an XML file.  /etc/xdg/menus/lxde-applications.menu is the system-wide menu file, and the user-specific menu file is ~/.config/menus/lxde-applications.menu.

3. Editing the menu:
A. To create a new menu item (a launcher) for a program that is not in your menu, use the AVLinux Control Panel and add the program to you user's menu or the system-wide menu, as desired.  To delete a launcher you created, go to the proper /applications directory and delete the file you created.  See the AVLinux User Manual for more details.

B. To change where a program shows up in the menu, you can edit the launcher for that program (as described in the AVLinux Manual), or you can edit the lxde-applications.menu file.  This is more difficult, but your changes will persist (unlike editing the launcher, where your changes will be overwritten if you upgrade the package whose launcher you edited).

4. Editing lxde-applications.menu:
You could edit the system-wide menu file as root (remember, it's /etc/xdg/menus/lxde-applications.menu), but XML files are picky about typos, and you could very quickly find yourself with a broken menu or no menu at all.  Much safer is to edit ~/.config/menus/lxde-applications.menu - no need for root privileges, and if you mess it up, just delete it and the system will re-generate your menu from the system-wide file.

lxde-applications.menu is formatted like this:
Code: [Select]
<!-- Graphics -->
<Menu>
<Name>Graphics</Name>
<Directory>lxde-graphics.directory</Directory>
<Include>
<And>
<Category>Graphics</Category>
<Not><Category>Utility</Category></Not>
</And>
</Include>
</Menu> <!-- End Graphics -->
This snippet creates the 'Graphics' menu, and everything between <Menu> and </Menu> is viewed as a part of this. <!-- this is a comment. -->
Everything in here is human-readable, items start with < > and end with </ >.  This is where typos are easy, if an item is not ended properly, the rest of the file is viewed as a part of that item, causing obvious problems.

By using <Include> and <Not>, you can add or exclude any program to or from any menu or submenu.

And with a snippet like this, you can add a sub-menu inside a menu:
Code: [Select]
<!-- Plugins -->
<Menu>
<Name>Plugins</Name>
<Directory>lxde-plugins.directory</Directory>
<Include>
                   <Filename>calf.desktop</Filename>
                   <Filename>jack-rack.desktop</Filename>
                   <Filename>jamin.desktop</Filename>
                   <Filename>Jc_Gui.desktop</Filename>
                   <Filename>lv2rack.desktop</Filename>
<And>
<Category>Plugins</Category>
</And>
</Include>
</Menu> <!-- End Plugins -->
Here, I moved the JACK plugins menu inside the Audio menu and added a few programs to it.

To see your changes, save ~/.config/menus/lxde-applications.menu and click on your main menu.  It takes about a second to refresh and apply the changes.

Finally, to finish off this mammoth post, here is a complete copy of my current ~/.config/menus/lxde-applications.menu file.  To check it out, just copy and paste this into gedit, and save it in the correct location.  You'll probably want to back up whatever is there, as what is right for me is most likely not right for you.
Code: [Select]
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
 "http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">

<Menu>

<Name>Applications</Name>
<Directory>lxde-menu-applications.directory</Directory>

<!-- Read standard .directory and .desktop file locations -->
<DefaultAppDirs/>
<DefaultDirectoryDirs/>

<!-- Read in overrides and child menus from applications-merged/ -->
<DefaultMergeDirs/>

<!-- Accessories submenu -->
<Menu>
<Name>Accessories</Name>
<Directory>lxde-utility.directory</Directory>
<Include>
<And>
<Category>Utility</Category>
<!-- Accessibility spec must have either the Utility or Settings
category, and we display an accessibility submenu already for
the ones that do not have Settings, so don't display accessibility
applications here -->
<Not><Category>Accessibility</Category></Not>
<Not><Category>System</Category></Not>
</And>
</Include>
</Menu> <!-- End Accessories -->

<!-- Accessibility submenu -->
<Menu>
<Name>Universal Access</Name>
<Directory>lxde-utility-accessibility.directory</Directory>
<Include>
<And>
<Category>Accessibility</Category>
<Not><Category>Settings</Category></Not>
</And>
</Include>
</Menu> <!-- End Accessibility -->

<!-- Development Tools -->
<Menu>
<Name>Development</Name>
<Directory>lxde-development.directory</Directory>
<Include>
<And>
<Category>Development</Category>
</And>
<Filename>emacs.desktop</Filename>
</Include>
</Menu> <!-- End Development Tools -->

<!-- Education -->
<Menu>
<Name>Education</Name>
<Directory>lxde-education.directory</Directory>
<Include>
<And>
<Category>Education</Category>
<Not>
<Filename>denemo.desktop</Filename>
<Filename>xiphos.desktop</Filename>
</Not>
</And>

</Include>
</Menu> <!-- End Education -->

<!-- Games -->
<Menu>
<Name>Games</Name>
<Directory>lxde-game.directory</Directory>
<Include>
<And>
<Category>Game</Category>
</And>
</Include>
</Menu> <!-- End Games -->

<!-- Graphics -->
<Menu>
<Name>Graphics</Name>
<Directory>lxde-graphics.directory</Directory>
<Include>
<And>
<Category>Graphics</Category>
<Not><Category>Utility</Category></Not>
</And>
</Include>
</Menu> <!-- End Graphics -->

<!-- Internet -->
<Menu>
<Name>Internet</Name>
<Directory>lxde-network.directory</Directory>
<Include>
<And>
<Category>Network</Category>
</And>
</Include>
</Menu> <!-- End Internet -->

<!-- Multimedia -->
<Menu>
<Name>Multimedia</Name>
<Directory>lxde-audio-video.directory</Directory>
                <Menu>      <!-- Midi and Synths -->
                         <Name>Midi and Synths</Name>
                         <Directory>lxde-midi.directory</Directory>
                         <Include>
                             <Filename>a2jmidid.desktop</Filename>
     <Filename>aeolus.desktop</Filename>
     <Filename>arpage.desktop</Filename>
                             <Filename>bristol-launch.desktop</Filename>
                             <Filename>harmonyseq.desktop</Filename>
     <Filename>jack-keyboard.desktop</Filename>
                             <Filename>oom.desktop</Filename>
                             <Filename>qsampler.desktop</Filename>
                             <Filename>qsynth.desktop</Filename>
                             <Filename>Pianoteq.desktop</Filename>
                             <Filename>phasex.desktop</Filename>
                             <Filename>rosegarden.desktop</Filename>
     <Filename>specimen.desktop</Filename>
                             <Filename>swami.desktop</Filename>
                             <Filename>vmpk.desktop</Filename>
                             <Filename>yoshimi.desktop</Filename>
                             <Filename>zynaddsubfx.desktop</Filename>
                             <Filename>zynjacku.desktop</Filename>
                             <Filename>zonage.desktop</Filename>
                         </Include>
                </Menu>  <!-- End Midi and Synths -->
<!-- Plugins -->
<Menu>
<Name>Plugins</Name>
<Directory>lxde-plugins.directory</Directory>
<Include>
                   <Filename>calf.desktop</Filename>
                   <Filename>jack-rack.desktop</Filename>
                   <Filename>jamin.desktop</Filename>
                   <Filename>Jc_Gui.desktop</Filename>
                   <Filename>lv2rack.desktop</Filename>
<And>
<Category>Plugins</Category>
</And>
</Include>
</Menu> <!-- End Plugins -->
<Menu> <!-- Scores and Typesetting -->
<Name>Scores</Name>
<Directory>lxde-scores.directory</Directory>
<Include>
    <Filename>audiveris.desktop</Filename>
                    <Filename>Chordata.desktop</Filename>
    <Filename>denemo.desktop</Filename>
    <Filename>mscore.desktop</Filename>
    <Filename>tuxguitar.desktop</Filename>
    <Filename>transcribe.desktop</Filename>
<And>
<Category>X.scores</Category>
</And>
</Include>
</Menu>
<!-- End Scores and Typesetting -->

        <!-- Soundcard -->
<Menu>
<Name>Soundcard</Name>
<Directory>lxde-soundcard.directory</Directory>
<Include>
                   <Filename>aumix-gtk.desktop</Filename>
                   <Filename>echomixer.desktop</Filename>
                   <Filename>envy24_control.desktop</Filename>
                   <Filename>ffado.org-ffadomixer.desktop</Filename>
                   <Filename>gnome-alsamixer.desktop</Filename>
                   <Filename>gnome-sound-recorder.desktop</Filename>
                   <Filename>gnome-volume-control.desktop</Filename>
                   <Filename>hdspconf.desktop</Filename>
                   <Filename>hdspmixer.desktop</Filename>
                   <Filename>mudita24control.desktop</Filename>
                   <Filename>rmedigicontrol.desktop</Filename>
                   <Filename>wineasio.desktop</Filename>
<And>
<Category>Soundcard</Category>
</And>
</Include>
</Menu> <!-- End Soundcard -->

<Include>
                   <Filename>amarok.desktop</Filename>
                   <Filename>aqualung.desktop</Filename>
                   <Filename>ardour.desktop</Filename>
                   <Filename>ardourvst.desktop</Filename>
                   <Filename>asunder.desktop</Filename>
                   <Filename>audacious2.desktop</Filename>
                   <Filename>audacity.desktop</Filename>
                   <Filename>brasero.desktop</Filename>
                   <Filename>clementine.desktop</Filename>
                   <Filename>fmit.desktop</Filename>
                   <Filename>exaile.desktop</Filename>
                   <Filename>festige.desktop</Filename>
                   <Filename>floola.desktop</Filename>
   <Filename>gcdmaster.desktop</Filename>
                   <Filename>gigedit.desktop</Filename>
                   <Filename>gnomebaker.desktop</Filename>
                   <Filename>gnormalize.desktop</Filename>
                   <Filename>goobox.desktop</Filename>
                   <Filename>grip.desktop</Filename>
                   <Filename>gstreamer-properties.desktop</Filename>
                   <Filename>gtkpod.desktop</Filename>
                   <Filename>guitarix.desktop</Filename>
                   <Filename>gx_head.desktop</Filename>
                   <Filename>hydrogen.desktop</Filename>
                   <Filename>muse.desktop</Filename>
                   <Filename>qjackctl.desktop</Filename>
                   <Filename>jack_mixer.desktop</Filename>
                   <Filename>k3b.desktop</Filename>
                   <Filename>mhwaveedit.desktop</Filename>
                   <Filename>lingot.desktop</Filename>
                   <Filename>lmms.desktop</Filename>
                   <Filename>lxmusic.desktop</Filename>
                   <Filename>non-daw.desktop</Filename>
                   <Filename>non-mixer.desktop</Filename>
                   <Filename>non-sequencer.desktop</Filename>
                   <Filename>patchage.desktop</Filename>
                   <Filename>potamus.desktop</Filename>
                   <Filename>qtractor.desktop</Filename>
                   <Filename>radiotray.desktop</Filename>
                   <Filename>rakarrack.desktop</Filename>
                   <Filename>rhythmbox.desktop</Filename>
   <Filename>SlowMP3.desktop</Filename>
                   <Filename>songbird.desktop</Filename>
                   <Filename>sonic-visualiser.desktop</Filename>
                   <Filename>sooperlooper.desktop</Filename>
                   <Filename>sound-juicer.desktop</Filename>
                   <Filename>sweep.desktop</Filename>
                   <Filename>xcdroast.desktop</Filename>
                    <And>
<Category>AudioEditing</Category>
</And>
</Include>
</Menu> <!-- End Multimedia -->

       <!-- Video -->
<Menu>
<Name>Video</Name>
<Directory>lxde-video.directory</Directory>
<Include>
                  <Filename>avidemux-gtk.desktop</Filename>
                  <Filename>blender-fullscreen.desktop</Filename>
                  <Filename>blender-windowed.desktop</Filename>
                  <Filename>bombono-dvd.desktop</Filename>
                  <Filename>cheese.desktop</Filename>
                  <Filename>cinelerra.desktop</Filename>
                  <Filename>devede.desktop</Filename>
                  <Filename>ekd.desktop</Filename>
                  <Filename>gtk-recordmydesktop.desktop</Filename>
                  <Filename>ghb.desktop</Filename>
                  <Filename>guvcview.desktop</Filename>
  <Filename>kazam.desktop</Filename>
                  <Filename>Kino.desktop</Filename>
                  <Filename>kdenlive.desktop</Filename>
                  <Filename>LiVES.desktop</Filename>
                  <Filename>mediainfo-gui.desktop</Filename>
                  <Filename>openshot.desktop</Filename>
                  <Filename>pitivi.desktop</Filename>
                  <Filename>totem.desktop</Filename>
                  <Filename>v4l2ucp.desktop</Filename>
                  <Filename>vlc.desktop</Filename>
                  <Filename>winff.desktop</Filename>
                  <Filename>xine.desktop</Filename>
                  <Filename>xjadeo.desktop</Filename>
                  <Filename>xvidcap.desktop</Filename>
  <And>
<Category>VideoEditing</Category>
</And>
</Include>
</Menu> <!-- End Video -->

        <!-- Office -->
<Menu>
<Name>Office</Name>
<Directory>lxde-office.directory</Directory>
<Include>
<And>
<Category>Office</Category>
</And>
</Include>
</Menu> <!-- End Office -->

<!-- System Tools-->
<Menu>
<Name>System</Name>
<Directory>lxde-system-tools.directory</Directory>
<Include>
<And>
<Category>System</Category>
<Not><Category>Settings</Category></Not>
<Not><Category>PackageManager</Category></Not>
</And>
</Include>
</Menu> <!-- End System Tools -->

<!-- Other -->
<Menu>
<Name>Other</Name>
<Directory>lxde-other.directory</Directory>
<OnlyUnallocated/>
<Include>
<And>

</And>
</Include>
</Menu> <!-- End Other -->

<Menu>
<Name>DesktopSettings</Name>
<Directory>lxde-settings.directory</Directory>
<OnlyUnallocated/>
<Include>
<Or>
<Category>Settings</Category>
<Category>PackageManager</Category>
<Category>System</Category>
</Or>
</Include>
<Layout>
<Merge type="menus"/>
<Merge type="files"/>
</Layout>

</Menu> <!-- End Settings -->
       
<Layout>
<Merge type="files"/>
<Merge type="menus"/>
<Separator/>
<Menuname>DesktopSettings</Menuname>
</Layout>

</Menu> <!-- End Applications -->
Of course you'll be missing the .directory files I created, so my custom sub-menus won't have icons, but you'll be able to get the idea anyway.

That's all!  Thanks for reading.  Tips and suggestions (especially suggestions relating to better menu structure) are welcome.
« Last Edit: September 17, 2011, 07:42:54 PM by trulan »

Offline Prof Knaakenbroed

  • Hero Member
  • *****
  • Posts: 100
  • Karma: +0/-0
    • Prof Knaakenbroed - Music
Re: HowTo: Customize your main menu
« Reply #1 on: September 21, 2011, 02:23:23 PM »
thanks for sharing your knowledge  :howdy:

that will help a lot to customize or to explain WHY things work as they do

great article

Yours

ProfKnaakenbroed

Offline Rita G.

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: HowTo: Customize your main menu
« Reply #2 on: October 16, 2011, 11:39:12 PM »
can someone please write a how-to on starting a thread? i can't find any option to do this here in this forum.

Offline trulan

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 910
  • Karma: +1/-0
Re: HowTo: Customize your main menu
« Reply #3 on: October 17, 2011, 06:34:25 AM »
Go to your desired sub-forum (eg. AVLinux, HowTO's); on the far right side just above the thread listing is a 'New Topic' button.  It is a bit small and un-obvious, now that you mention it.

Offline Rita G.

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: HowTo: Customize your main menu
« Reply #4 on: October 17, 2011, 01:21:13 PM »
i logged in with iceweasel, chromium and iceape on 2 different computers and there is no "new topic" button anywhere on any page.

Offline Rita G.

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: HowTo: Customize your main menu
« Reply #5 on: October 17, 2011, 01:24:17 PM »
ok.....my apologies!
i found out what i did wrong..

Offline neardeathmoment

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: HowTo: Customize your main menu
« Reply #6 on: May 27, 2013, 01:29:55 AM »
You could edit the system-wide menu file as root (remember, it's /etc/xdg/menus/lxde-applications.menu), but XML files are picky about typos, and you could very quickly find yourself with a broken menu or no menu at all. 

Each to their own, but I've found that manually editing the text config files is very error-prone.  In my opinion, it's best to use an application specifically suited for this purpose.  I have found the program "kmenuedit" works very well for this purpose.