Page 1 of 1

filepipe.pl, a file browsing menu for Openbox

Posted: 31. Oct 2015, 16:26
by GJones

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>";
Obviously, you change the terminal and shell based on your preferences...

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.