filepipe.pl, a file browsing menu for Openbox

Other talk about Salix
Post Reply
GJones
Donor
Posts: 300
Joined: 22. Jul 2011, 23:27

filepipe.pl, a file browsing menu for Openbox

Post 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.
Post Reply