Browse Source

Merge pull request #30 from digital-freak/master

Add support for Openbox pipe-menus
master
George Vlahavas 5 months ago
committed by GitHub
parent
commit
11b0da0de3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      .gitignore
  2. 30
      man/xdgmenumaker.t2t
  3. 49
      src/xdgmenumaker
  4. 2
      tests/Makefile
  5. 388
      tests/menus_correct/openbox

1
.gitignore

@ -1,2 +1,3 @@
tests/menus_test
man/xdgmenumaker.1
*.orig

30
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:
``<Program label="Refresh Menu">jwm -reload</Program>``
: **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 //<menu id="root-menu" label="Openbox 3">// section:
``<menu execute="cat ~/.cache/openbox/apps.menu" id="applications-pipe-menu" label="Applications"/>``
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:
```
<item label="Rebuild applications menu">
<action name="Execute">
<command>xdgmenumaker -i -f openbox > ~/.cache/openbox/apps.menu</command>
</action>
</item>
```
: **pekwm**
There are two ways to have an XDG menu in pekwm. The first one,

49
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('<?xml version="1.0" encoding="UTF-8"?>')
print('<openbox_pipe_menu>')
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}<menu id="{d}" label="{c}" icon="{i}">'
.format(s=spacing, d=cat_id, c=cat_name, i=cat_icon))
else:
print('{s}<menu id="{d}" label="{c}">'
.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}<item label="{n}" icon="{i}">'
.format(s=spacing, n=name, i=icon))
else:
print('{s}{s}<item label="{n}">'
.format(s=spacing, n=name))
print('{s}{s}{s}<action name="Execute">'.format(s=spacing))
print('{s}{s}{s}{s}<command>{c}</command>'.format(s=spacing,
c=command))
print('{s}{s}{s}</action>'.format(s=spacing))
print('{s}{s}</item>'.format(s=spacing))
print('{s}</menu>'.format(s=spacing))
print('</openbox_pipe_menu>')
if __name__ == "__main__":
main(sys.argv[1:])

2
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 \

388
tests/menus_correct/openbox

@ -0,0 +1,388 @@
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
<menu id="apps-accessories-menu" label="Accessories">
<item label="Engrampa Archive Manager">
<action name="Execute">
<command>engrampa </command>
</action>
</item>
<item label="GTKMan Manual Page Viewer">
<action name="Execute">
<command>gtkman salix</command>
</action>
</item>
<item label="Galculator">
<action name="Execute">
<command>galculator</command>
</action>
</item>
<item label="KeePassX">
<action name="Execute">
<command>keepassx </command>
</action>
</item>
<item label="Leafpad">
<action name="Execute">
<command>leafpad </command>
</action>
</item>
<item label="Search for Files...">
<action name="Execute">
<command>mate-search-tool</command>
</action>
</item>
<item label="Take Screenshot">
<action name="Execute">
<command>mate-screenshot --interactive</command>
</action>
</item>
<item label="Xournal">
<action name="Execute">
<command>xournal </command>
</action>
</item>
<item label="Zim Desktop Wiki">
<action name="Execute">
<command>zim</command>
</action>
</item>
</menu>
<menu id="apps-development-menu" label="Development">
<item label="CMake">
<action name="Execute">
<command>cmake-gui </command>
</action>
</item>
<item label="Geany">
<action name="Execute">
<command>geany </command>
</action>
</item>
<item label="Glade">
<action name="Execute">
<command>glade-3 </command>
</action>
</item>
<item label="Meld">
<action name="Execute">
<command>meld </command>
</action>
</item>
<item label="Poedit">
<action name="Execute">
<command>poedit </command>
</action>
</item>
<item label="Qt4 Assistant">
<action name="Execute">
<command>assistant</command>
</action>
</item>
<item label="Qt4 Designer">
<action name="Execute">
<command>designer</command>
</action>
</item>
<item label="Qt4 Linguist">
<action name="Execute">
<command>linguist</command>
</action>
</item>
<item label="RStudio">
<action name="Execute">
<command>/usr/lib64/rstudio/bin/rstudio </command>
</action>
</item>
</menu>
<menu id="apps-education-menu" label="Education">
<item label="R">
<action name="Execute">
<command>xterm -e R</command>
</action>
</item>
</menu>
<menu id="apps-games-menu" label="Games">
<item label="KEGS">
<action name="Execute">
<command>xterm -e aoss xkegs</command>
</action>
</item>
</menu>
<menu id="apps-graphics-menu" label="Graphics">
<item label="Dia Diagram Editor">
<action name="Execute">
<command>dia </command>
</action>
</item>
<item label="E-book Viewer">
<action name="Execute">
<command>ebook-viewer </command>
</action>
</item>
<item label="GNU Image Manipulation Program">
<action name="Execute">
<command>gimp-2.8 </command>
</action>
</item>
<item label="Gcolor2">
<action name="Execute">
<command>gcolor2</command>
</action>
</item>
<item label="LRF Viewer">
<action name="Execute">
<command>lrfviewer </command>
</action>
</item>
<item label="Simple Scan">
<action name="Execute">
<command>simple-scan</command>
</action>
</item>
<item label="Viewnior">
<action name="Execute">
<command>viewnior </command>
</action>
</item>
</menu>
<menu id="apps-multimedia-menu" label="Multimedia">
<item label="Asunder CD Ripper">
<action name="Execute">
<command>asunder</command>
</action>
</item>
<item label="Audacity">
<action name="Execute">
<command>audacity </command>
</action>
</item>
<item label="Ex Falso">
<action name="Execute">
<command>exfalso</command>
</action>
</item>
<item label="Exaile">
<action name="Execute">
<command>exaile </command>
</action>
</item>
<item label="GNOME MPlayer">
<action name="Execute">
<command>gnome-mplayer </command>
</action>
</item>
<item label="Gaupol">
<action name="Execute">
<command>gaupol </command>
</action>
</item>
<item label="ISO Master">
<action name="Execute">
<command>isomaster</command>
</action>
</item>
<item label="Quod Libet">
<action name="Execute">
<command>quodlibet</command>
</action>
</item>
</menu>
<menu id="apps-network-menu" label="Network">
<item label="Claws Mail">
<action name="Execute">
<command>claws-mail </command>
</action>
</item>
<item label="Firefox">
<action name="Execute">
<command>firefox </command>
</action>
</item>
<item label="Pidgin Internet Messenger">
<action name="Execute">
<command>pidgin</command>
</action>
</item>
<item label="Transmission">
<action name="Execute">
<command>transmission-gtk </command>
</action>
</item>
<item label="gFTP">
<action name="Execute">
<command>gftp </command>
</action>
</item>
<item label="ownCloud desktop sync client">
<action name="Execute">
<command>/usr/bin/owncloud</command>
</action>
</item>
</menu>
<menu id="apps-office-menu" label="Office">
<item label="Atril Document Viewer">
<action name="Execute">
<command>atril </command>
</action>
</item>
<item label="Dictionary">
<action name="Execute">
<command>mate-dictionary</command>
</action>
</item>
<item label="HTMLDOC">
<action name="Execute">
<command>htmldoc </command>
</action>
</item>
<item label="LibreOffice 4.4 Base">
<action name="Execute">
<command>libreoffice4.4 --base </command>
</action>
</item>
<item label="LibreOffice 4.4 Calc">
<action name="Execute">
<command>libreoffice4.4 --calc </command>
</action>
</item>
<item label="LibreOffice 4.4 Draw">
<action name="Execute">
<command>libreoffice4.4 --draw </command>
</action>
</item>
<item label="LibreOffice 4.4 Impress">
<action name="Execute">
<command>libreoffice4.4 --impress </command>
</action>
</item>
<item label="LibreOffice 4.4 Math">
<action name="Execute">
<command>libreoffice4.4 --math </command>
</action>
</item>
<item label="LibreOffice 4.4 Writer">
<action name="Execute">
<command>libreoffice4.4 --writer </command>
</action>
</item>
<item label="calibre">
<action name="Execute">
<command>calibre </command>
</action>
</item>
</menu>
<menu id="apps-settings-menu" label="Settings">
<item label="Bluetooth Manager">
<action name="Execute">
<command>blueman-manager</command>
</action>
</item>
<item label="Power Management">
<action name="Execute">
<command>mate-power-preferences</command>
</action>
</item>
<item label="Qt4 Config">
<action name="Execute">
<command>qtconfig</command>
</action>
</item>
<item label="Screensaver">
<action name="Execute">
<command>xscreensaver-demo</command>
</action>
</item>
</menu>
<menu id="apps-system-menu" label="System">
<item label="ALSA sound card">
<action name="Execute">
<command>gksu gtkalsasetup</command>
</action>
</item>
<item label="Disk Usage Analyzer">
<action name="Execute">
<command>mate-disk-usage-analyzer</command>
</action>
</item>
<item label="Dotnew">
<action name="Execute">
<command>gksu dotnew-gtk</command>
</action>
</item>
<item label="Grsync">
<action name="Execute">
<command>/usr/bin/grsync -i </command>
</action>
</item>
<item label="Gslapt Package Manager">
<action name="Execute">
<command>gksu /usr/sbin/gslapt</command>
</action>
</item>
<item label="Hostnames">
<action name="Execute">
<command>gksu gtkhostsetup</command>
</action>
</item>
<item label="Htop">
<action name="Execute">
<command>xterm -e htop</command>
</action>
</item>
<item label="Keyboard">
<action name="Execute">
<command>gksu gtkkeyboardsetup</command>
</action>
</item>
<item label="Log File Viewer">
<action name="Execute">
<command>mate-system-log</command>
</action>
</item>
<item label="MATE Terminal">
<action name="Execute">
<command>mate-terminal</command>
</action>
</item>
<item label="Manage Printing">
<action name="Execute">
<command>/usr/bin/xdg-open http://localhost:631/</command>
</action>
</item>
<item label="Power Statistics">
<action name="Execute">
<command>mate-power-statistics</command>
</action>
</item>
<item label="Sourcery SlackBuild Manager">
<action name="Execute">
<command>gksu sourcery</command>
</action>
</item>
<item label="System clock">
<action name="Execute">
<command>gksu gtkclocksetup</command>
</action>
</item>
<item label="System language">
<action name="Execute">
<command>gksu gtklocalesetup</command>
</action>
</item>
<item label="System services">
<action name="Execute">
<command>gksu gtkservicesetup</command>
</action>
</item>
<item label="Users and groups">
<action name="Execute">
<command>gksu gtkusersetup</command>
</action>
</item>
<item label="dconf Editor">
<action name="Execute">
<command>dconf-editor</command>
</action>
</item>
</menu>
</openbox_pipe_menu>
Loading…
Cancel
Save