From a93e20af642276dad9c69d141a716e328eaf0204 Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Tue, 8 Nov 2016 01:36:33 +0200 Subject: [PATCH] Add --twm-titles option Add a --twm-titles option that adds a header title to each menu category. Naturally, only works for TWM. --- man/xdgmenumaker.t2t | 4 ++++ src/xdgmenumaker | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/man/xdgmenumaker.t2t b/man/xdgmenumaker.t2t index 83826f2..491825f 100644 --- a/man/xdgmenumaker.t2t +++ b/man/xdgmenumaker.t2t @@ -80,6 +80,10 @@ generated menus for pekwm you have to use this option. Do not use it if you want to generate static menus for pekwm. Only works with //pekwm// of course. +: **--twm-titles** +display menu titles in TWM menus. Naturally, only has an effect when +used with //twm//. + = GENERAL OPTIONS = diff --git a/src/xdgmenumaker b/src/xdgmenumaker index bf15dba..0f317be 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -35,6 +35,7 @@ iconsize = 16 desktop = False submenu = True pekwmdynamic = False +twmtitles = False max_icon_size = False # the following line gets changed by the Makefile. If it is set to @@ -168,11 +169,13 @@ def main(argv): global iconsize global submenu global pekwmdynamic + global twmtitles global max_icon_size try: opts, args = getopt.getopt(argv, "hins:f:", ["help", "icons", "no-submenu", "pekwm-dynamic", + "twm-titles", "max-icon-size", "size=", "format="]) @@ -195,6 +198,8 @@ def main(argv): submenu = False elif opt in ("--pekwm-dynamic",): pekwmdynamic = True + elif opt in ("--twm-titles",): + twmtitles = True elif opt in ("--max-icon-size",): try: # Pillow is optional and loaded only if we want to restrict the @@ -252,6 +257,7 @@ def usage(): print(' windowmaker') print(' --max-icon-size restrict the icon sizes to the specified size') print(' --pekwm-dynamic generate dynamic menus for pekwm') + print(' --twm-titles show menu titles in twm menus') print(' -h, --help show this help message') print(' You have to specify the output format using the -f switch.') print() @@ -790,6 +796,8 @@ def twm(): if submenu: print('menu "xdgmenu"') print("{") + if twmtitles: + print(' "{a}" f.title'.format(a=apps_name)) for menu_category in menu(): category = menu_category.category cat_name = category.decode() @@ -800,6 +808,8 @@ def twm(): cat_name = category.decode() print('menu "{}"'.format(cat_name)) print("{") + if twmtitles: + print(' "{c}" f.title'.format(c=cat_name)) for app in menu_category.applist: name = app.name.decode() # for some apps (like netbeans) the command is launched with