diff --git a/.gitignore b/.gitignore index 7b6e710..30dc116 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tests/menus_test man/xdgmenumaker.1 +*.orig diff --git a/man/xdgmenumaker.t2t b/man/xdgmenumaker.t2t index b5c732b..fb25f5d 100644 --- a/man/xdgmenumaker.t2t +++ b/man/xdgmenumaker.t2t @@ -35,6 +35,7 @@ according to the running user locale settings. - fvwm - icewm - jwm +- openbox - pekwm - twm and compatible derivatives such as ctwm and vtwm - windowmaker @@ -49,8 +50,8 @@ dependency (used by the **--max-icon-size** option). : **-f, --format** specify the output format to use. Valid options are //amiwm//, //blackbox//, -//compizboxmenu//, //fluxbox//, //fvwm//, //icewm//, //jwm//, //pekwm//, -//twm// and //windowmaker//. +//compizboxmenu//, //fluxbox//, //fvwm//, //icewm//, //jwm//, //openbox//, +//pekwm//, //twm// and //windowmaker//. Specifying the output format is mandatory. : **-i, --icons** @@ -300,6 +301,31 @@ refresh the menu, like this: ``jwm -reload`` +: **Openbox** +To generate an application menu for Openbox, run **xdgmenumaker** like this: + +``$ xdgmenumaker -f openbox > ~/.cache/openbox/apps.menu`` + +or if you want icons in your menu: + +``$ xdgmenumaker -i -f openbox > ~/.cache/openbox/apps.menu`` + +and you can then edit your //~/.config/openbox/menu.xml// file and add this +line somewhere in //// section: + +```` + +You can add the **xdgmenumaker** command as another item in your menu, if +you want to update it, without having to run the command manually again: + +``` + + + xdgmenumaker -i -f openbox > ~/.cache/openbox/apps.menu + + +``` + : **pekwm** There are two ways to have an XDG menu in pekwm. The first one, diff --git a/src/xdgmenumaker b/src/xdgmenumaker index 8001d61..5131a26 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -230,6 +230,8 @@ def main(argv): elif xopts['desktop'] == "amiwm": xopts['seticon'] = False amiwm() + elif xopts['desktop'] == "openbox": + openbox() else: usage() sys.exit(2) @@ -241,7 +243,8 @@ def usage(): print('OPTIONS:') print(' -f, --format the output format to use.') print(' Valid options are amiwm, blackbox, compizboxmenu,') - print(' fluxbox, fvwm, twm, icewm, jwm, windowmaker and pekwm') + print(' fluxbox, fvwm, twm, icewm, jwm, openbox,') + print(' windowmaker and pekwm') print(' -i, --icons enable support for icons in the') print(' menus. Does not work with windowmaker or amiwm') print(' --no-svg Do not use SVG icons even for WMs that support it') @@ -290,8 +293,9 @@ def icon_full_path(icon): ext = os.path.splitext(icon)[1].lower() if os.path.exists(icon): if ext == ".svg" or ext == ".svgz": - # only jwm and icewm support svg icons - if (xopts['desktop'] == "jwm" or xopts['desktop'] == "icewm") and not xopts['nosvg']: + # only jwm, icewm and openbox support svg icons + if (xopts['desktop'] == "jwm" or xopts['desktop'] == "icewm" + or xopts['desktop'] == "openbox") and not xopts['nosvg']: return icon else: # icon is not svg @@ -303,8 +307,9 @@ def icon_full_path(icon): icon = icon_strip(icon) icon_theme = gtk.icon_theme_get_default() try: - # JWM and IceWM support svg icons - if (xopts['desktop'] == "jwm" or xopts['desktop'] == "icewm") and not xopts['nosvg']: + # JWM, IceWM and Openbox support svg icons + if (xopts['desktop'] == "jwm" or xopts['desktop'] == "icewm" + or xopts['desktop'] == "openbox") and not xopts['nosvg']: icon = icon_theme.lookup_icon(icon, xopts['iconsize'], gtk.ICON_LOOKUP_FORCE_SVG) # but none of the other WMs does else: @@ -880,6 +885,40 @@ def amiwm(): print(' ToolItem "{n}" "{c}" ""'.format(n=name, c=command)) print("}") +def openbox(): + print('') + print('') + spacing = ' ' + for menu_category in menu(): + category = menu_category.category + cat_name = category.decode() + cat_id = 'apps-{}-menu'.format(cat_name.lower()) + cat_icon = category_icon(category) + cat_icon = icon_full_path(cat_icon) + if xopts['seticon'] and cat_icon is not None: + print('{s}' + .format(s=spacing, d=cat_id, c=cat_name, i=cat_icon)) + else: + print('{s}' + .format(s=spacing, d=cat_id, c=cat_name)) + for app in menu_category.applist: + name = app.name.decode() + command = app.command + icon = app.icon + if xopts['seticon'] and icon is not None: + print('{s}{s}' + .format(s=spacing, n=name, i=icon)) + else: + print('{s}{s}' + .format(s=spacing, n=name)) + print('{s}{s}{s}'.format(s=spacing)) + print('{s}{s}{s}{s}{c}'.format(s=spacing, + c=command)) + print('{s}{s}{s}'.format(s=spacing)) + print('{s}{s}'.format(s=spacing)) + print('{s}'.format(s=spacing)) + print('') + if __name__ == "__main__": main(sys.argv[1:]) diff --git a/tests/Makefile b/tests/Makefile index 2bbdd91..8eb891e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -43,6 +43,8 @@ generate: $(PYTHON) $(MM) -f jwm -i > menus_test/jwm_icons XDGMENUMAKER_TEST=1 XDGMENUMAKERTERM=xterm LANG=fr_FR.utf8 \ $(PYTHON) $(MM) -f jwm > menus_test/jwm_fr + XDGMENUMAKER_TEST=1 XDGMENUMAKERTERM=xterm LANG=fr_FR.utf8 \ + $(PYTHON) $(MM) -f openbox > menus_test/openbox XDGMENUMAKER_TEST=1 XDGMENUMAKERTERM=xterm LANG=en_US.utf8 \ $(PYTHON) $(MM) -f pekwm > menus_test/pekwm XDGMENUMAKER_TEST=1 XDGMENUMAKERTERM=xterm LANG=en_US.utf8 \ diff --git a/tests/menus_correct/openbox b/tests/menus_correct/openbox new file mode 100644 index 0000000..5e7b144 --- /dev/null +++ b/tests/menus_correct/openbox @@ -0,0 +1,388 @@ + + + + + + engrampa + + + + + gtkman salix + + + + + galculator + + + + + keepassx + + + + + leafpad + + + + + mate-search-tool + + + + + mate-screenshot --interactive + + + + + xournal + + + + + zim + + + + + + + cmake-gui + + + + + geany + + + + + glade-3 + + + + + meld + + + + + poedit + + + + + assistant + + + + + designer + + + + + linguist + + + + + /usr/lib64/rstudio/bin/rstudio + + + + + + + xterm -e R + + + + + + + xterm -e aoss xkegs + + + + + + + dia + + + + + ebook-viewer + + + + + gimp-2.8 + + + + + gcolor2 + + + + + lrfviewer + + + + + simple-scan + + + + + viewnior + + + + + + + asunder + + + + + audacity + + + + + exfalso + + + + + exaile + + + + + gnome-mplayer + + + + + gaupol + + + + + isomaster + + + + + quodlibet + + + + + + + claws-mail + + + + + firefox + + + + + pidgin + + + + + transmission-gtk + + + + + gftp + + + + + /usr/bin/owncloud + + + + + + + atril + + + + + mate-dictionary + + + + + htmldoc + + + + + libreoffice4.4 --base + + + + + libreoffice4.4 --calc + + + + + libreoffice4.4 --draw + + + + + libreoffice4.4 --impress + + + + + libreoffice4.4 --math + + + + + libreoffice4.4 --writer + + + + + calibre + + + + + + + blueman-manager + + + + + mate-power-preferences + + + + + qtconfig + + + + + xscreensaver-demo + + + + + + + gksu gtkalsasetup + + + + + mate-disk-usage-analyzer + + + + + gksu dotnew-gtk + + + + + /usr/bin/grsync -i + + + + + gksu /usr/sbin/gslapt + + + + + gksu gtkhostsetup + + + + + xterm -e htop + + + + + gksu gtkkeyboardsetup + + + + + mate-system-log + + + + + mate-terminal + + + + + /usr/bin/xdg-open http://localhost:631/ + + + + + mate-power-statistics + + + + + gksu sourcery + + + + + gksu gtkclocksetup + + + + + gksu gtklocalesetup + + + + + gksu gtkservicesetup + + + + + gksu gtkusersetup + + + + + dconf-editor + + + +