Skip navigation.

Openbox 3 appdirs menu

Openbox 3 appdirs menu (httpAndrew Stephens)

OB3 uses XML for its configuration files, so I made my own small python script to create XML dynamic menu entries for files, appdirs, and normal directories (in that order). Files are opened/run using the rox filer (so it relies on what run action you've specified for the file type). Application Directories are simply run like usual, and normal directories are turned into their own submenus.
For your menu file, use an entry something like this:

<menu id="roxmenu-menu" label="ROX Menu" execute="/home/andrew/.config/openbox/scripts/ /home/andrew/Apps" />

This will give you a menu of all your files, appdirs, and directories in your personal Apps folder. I like to the script to take my ROX-Menu entries so I use '/home/andrew/Choices/ROX-Menu-bin/Menu_Root' as the argument for script. The main thing to note is that the script DOES require a path as an argument.
Here it is... I'm new to Python (n++ doesn't work?) so feel free to make it better - There probably should be some exception handling in it... among other things...


import sys
import os.path

print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
print "<openbox_pipe_menu>"

def scan( menu_path ):

        mylist = os.listdir( menu_path )

        filelist = []
        appdirlist = []
        dirlist = []
        for name in mylist:
                fullname = os.path.join( menu_path, name )
                fullappdir = os.path.join( fullname,"AppRun" )
                if os.path.isfile( fullname ):
                        if name <> ".DirIcon":
                                filelist.append( "<item label=\"" + name + "\"><action name=\"Execute\"><execute>rox \"" \
                                + fullname + "\"</execute></action></item>" )
                elif os.path.isdir( fullname ):
                        if os.path.exists( fullappdir ):
                                appdirlist.append( "<item label=\"" + name + "\"><action name=\"Execute\"><execute>" \
                                + fullappdir + "</execute></action></item>" )
                                dirlist.append( name )

        for f in filelist:
                print f

        for a in appdirlist:
                print a

        for d in dirlist:
                fullname = os.path.join( menu_path, d )
                print "<menu id=\"" + d + "\" label=\"" + d + "\">"
                scan( fullname )
                print "</menu>"

scan ( sys.argv[1] )

print "</openbox_pipe_menu>"

Syndicate content