Debian Wheezy release (next stable) come with:

  $ fvwm-config -v
  2.5.30

Debian have own menu system and I intensively use it. But time come and a few
people worry about old technologies. So new package have .desktop files with
high probability and have no menu files with zero probability.

I try to transform .desktop files in Fvwm readable format by:

  $ fvwm-menu-desktop --desktop gnome-sys
  $ fvwm-menu-desktop --type gtk --desktop gnome-user

as say fvwm-menu-desktop(1) and get near empty output:

  DestroyMenu "gnome-sys"
  AddToMenu "gnome-sys" "Gnome System Menu" Title

I know that problem in distros must be resolved at its bug tracker. But this
require long time delay...

I try find another solution but general search only point to fvwm-menu-desktop
(from mail list archive, fvwmforum and blog posts).

I try point fvwm-menu-desktop to Debian hierarchy:

  $ fvwm-menu-desktop --dir /usr/share/applications --name gnome-menu --title 
"Gnome menu"

  DestroyMenu "gnome-menu"
  AddToMenu "gnome-menu" "Gnome menu" Title
  + "kde4" Popup "gnome-menu-kde4-4"
  + "Skype" Exec exec skype
  + "GnuCash" Exec exec gnucash
  + "Qucs" Exec exec qucs
  + "DjView4" Exec exec djview4
  ...
  .....   260 lines without Popup
  ...
  + "digiKam" Exec exec digikam -caption "digiKam" 

and get result that does not satisfy my - all menu items in one looooong list.
I expect hierarchical organisation, like terminals, editors, games...

I check:

  http://standards.freedesktop.org/menu-spec/latest/

and present files:

  $ cat /usr/share/applications/supertuxkart.desktop

  [Desktop Entry]
  Name=SuperTuxKart
  Version=1.0
  Icon=supertuxkart
  GenericName=A kart racing game
  Exec=supertuxkart --log=file
  Terminal=false
  StartupNotify=false
  Type=Application
  TryExec=supertuxkart
  Categories=Game;ArcadeGame;

So I decide that .desktop files provide enough info (look to 'Categories'
field) to make hierarchical.

Also I examine 'fvwm-menu-desktop' script:

  $ grep -i Categories <`which fvwm-menu-desktop` || error not found
  not found

Also specs say about menu files:

  http://standards.freedesktop.org/menu-spec/latest/ar01s04.html
                Menu files must be well-formed XML files and end in the
                extension ".menu".

fvwm-menu-desktop have no any xml related code...

Same problems reposter 3 years ago:

  http://www.mail-archive.com/fvwm-workers@fvwm.org/msg01899.html
                Re: fvwm-menu-desktop, xdg-menus

================================================================

Another question about FvwmGtk which mentioned in fvwm-menu-desktop(1).

It is currently doesn't ship in Debian. Does anyone know that a problem with
FvwmGtk as it rejected by Debian?

================================================================

After a far bit more googling I found script:

  http://pastebin.com/ktGaAcgw
                xdg-menu.py

which uses xdg Python library to convert .menu, .desktop and .directory to
Fvwm menus.

I simplify it (remove image conversion and so remove dependency on "import
gtk") for Debian:


  import sys
  import os

  import xdg.Menu
  from xdg.DesktopEntry import *

  sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

  # For testing purpose. Uncomment to run this file without args...
  # sys.argv.append('debian-menu')

  if len(sys.argv) >= 2:
      sys_menu_name = sys.argv[1]
  else:
      print("You forget pass NAME which is /etc/xdg/NAME.menu")
      exit(1)

  # xdg_config_dirs hold possible paths. We use Debian one.
  sys_menu_file = "%s/menus/%s.menu" % ("/etc/xdg", sys_menu_name)

  sys_menu = xdg.Menu.parse(sys_menu_file)

  def parse_menu(menu, name):
      ''' Parse menu file. '''
      print 'DestroyMenu recreate %s' % name
      for entry in menu.getEntries():
          if isinstance(entry, xdg.Menu.Menu):
              icon = entry.getIcon()
              subname = name+"-"+str(entry)
              print u'AddToMenu "%s" "%s%%folder.png%%" Popup "%s"' % (name, 
entry.getName(), subname)
              parse_menu(entry, subname)
          elif isinstance(entry, xdg.Menu.MenuEntry):
              desktop = DesktopEntry(entry.DesktopEntry.getFileName())
              icon = desktop.getIcon()
              ind = icon.rfind('.')
              if ind != -1:
                  icon = icon[0:ind]
              cmd = desktop.getExec().rstrip('%FUfu')
              print u'AddToMenu "%s" "%s%%%s.png%%" Exec exec %s' % (name, 
desktop.getName(), os.path.basename(icon), cmd)
          else:
              pass

  parse_menu(sys_menu, "Menu-"+sys_menu_name)

and integrate in my installation Makefile:

  .PHONY: install
  install:
    mkdir ~/.fvwm
    cp .fvwm/config ~/.fvwm
    for f in /etc/xdg/menus/*.menu; do \
        f=$${f%.menu}; \
        f=$${f#/etc/xdg/menus/}; \
        python .fvwm/xdg2fvwm.py $$f >~/.fvwm/$$f.hook; \
        echo "Read $$[HOME]/.fvwm/$$f.hook" >>~/.fvwm/config; \
        echo "AddToMenu MenuMyRoot $$f Popup Menu-$$f" >>~/.fvwm/config; \
    done

To make all work I install:

  $ sudo apt-get install python-xdg

to satisfy script dependency and:

  $ sudo apt-get install gnome-menus

for Gnome /etc/xdh/menus/gnome-applications.menu file and:

  $ sudo apt-get install kdelibs5-data

for KDE /etc/xdh/menus/kde4-applications.menu file.

Full solution available in Mercurial VCS:

  https://sourceforge.net/u/gavenkoa/skel/ci/tip/tree/.fvwm/
  https://sourceforge.net/u/gavenkoa/skel/ci/tip/tree/Makefile

================================================================

Also I discover these highly useful links:

  https://wiki.archlinux.org/index.php/Xdg-menu
  http://wiki.mandriva.com/en/Development/Howto/MenuMigrationToXDG
  http://wiki.debian.org/DebianMenu
  http://wiki.debian.org/DesktopDefaultSettings
  http://standards.freedesktop.org/menu-spec/latest/
  http://wiki.debian.org/Proposals/DebianMenuUsingDesktopEntries

================================================================

I hope this info save time for other people.

Any comments are welcome!

-- 
Best regards!


Reply via email to