Code: Select all
#!/usr/bin/env perl
use strict;
use warnings;
use File::Find;
my $TERM = "xterm +sb -fg gray90 -bg gray10 -fa Monospace-9";
my $SHELL = "zsh";
my @search_dirs = @ARGV;
my @entries;
sub wanted {
my $name = $File::Find::name;
if (-d $name && $name !~ m/\/\./) {
push @entries, $File::Find::name;
}
}
File::Find::find(\&wanted, @search_dirs);
@entries = sort(@entries);
print "<openbox_pipe_menu>";
for my $entry (@entries) {
print "<item label=\"$entry\"><action name=\"Execute\">";
print "<command>$TERM -e 'chdir \"$entry\"; exec $SHELL'</command>";
print "</action></item>";
}
print "</openbox_pipe_menu>";
It's not as good as it could be. Most notably, it just lists directory contents in alphabetical order, rather than creating a nested hierarchy of menu entries. But it works well enough for my purposes.