Skip navigation.

Script to add ROX and AppDirs to the openbox menu

After I switched from the fluxbox wm to the openbox wm, I noticed in the
docs that for this wm one can generate menu items dynamicly by external
scripts. Below a small perl script that walks through the filesystem
generating menu entries that open a directory with rox. Also, more
interesting, if it encounters AppDirs, program entries are generated.
To use it edit ~/.openbox/menu (or /usr/share/commonbox/menu) to include
for example :

  [pipe] (/)    {/path/to/ /}
  [pipe] (Apps) {/path/to/ /usr/local/apps ~/apps}

Thus you can open any dir via the '/' entry and apps are automatically
listed under the 'Apps' entry.
File given below.

$no_idx = $#ARGV;
die "$0 needs a directory as argument.\n" unless @ARGV;
for (@ARGV) {
        $dir = $_ || next;
        opendir DIR, $dir || die "Could not open $dir\n";
        print "[exec] (.)  {rox $dir}\n"   unless $no_idx;
        $dir =~ s#/$##;
        print "[pipe] (..) {$0 $dir/..}\n" unless $no_idx;
        push @entries,
                map {   -x "$dir/$_/AppRun"
                        ? [$_, "[exec] ($_) {$dir/$_/AppRun}\n"]
                        : [$_, "[pipe] ($_) {$0 $dir/$_}\n"]
                grep {$_ !~ /^\./ and -d "$dir/$_"}
                readdir DIR;
        closedir DIR;
print map {$$_[1]} sort {$$a[0] cmp $$b[0]} @entries;

Syndicate content