From f0c632076fbb3dc93b426efdfa9bacc4c044df96 Mon Sep 17 00:00:00 2001 From: digital-freak Date: Thu, 25 Jul 2024 15:05:01 +0500 Subject: [PATCH] Add support Openbox pipe-menus --- man/xdgmenumaker.t2t | 30 +++++++++++++++++++++++++-- src/xdgmenumaker | 49 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 7 deletions(-) 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:])