[openbox] Ideas with recursive filesystem browsing pipe menu?
John Russell
drjimmy42 at yahoo.com
Mon May 17 10:08:07 EDT 2004
Maybe a "My Documents" menu that could open a file manager for
directories and certain apps for file extensions? If you pass rox a
file it will call the appropriate app for the file. That might be
useful.
On Mon, 2004-05-17 at 00:57 -0500, dircha wrote:
> Hello list,
>
> Can anyone think of something interesting we could do with a recursive
> filesystem browsing pipe menu?
>
> I just threw the together the attached script one evening as a proof of
> concept of this.
>
> Directories become sub-pipe menus Symlinks and files are static entries
> just now.
>
> One idea I had was to make files into submenus as well with an "edit"
> and "see" link and then use some environment mime information to launch
> the appropriate application for that file.
>
> Symlinks should probably just be resolved into their respective files
> and directories.
>
> An application independent recently used files list might be useful as
> well. Filter for certain useful document types and watch with dnotify.
> Or maybe just run the appropriate ls and sort per invocation on user
> specified directories.
>
> I run a fairly bare X environment: no GNOME or KDE environment or
> applications, mostly xterms. So it seemed to me that something along
> these lines might be useful.
>
> Menu entry:
> <menu id="mime_browse_menu" label="mime_browse" execute="browse ~" />
>
> ~/bin/browse perl script is attached as "browse".
>
> dircha
> plain text document attachment (browse)
> #!/usr/bin/perl
>
> use strict;
>
> my $path = $ARGV[0];
>
> my @files = split /\n/, `ls -A1p $path`;
> mk_menu_element($path, @files);
>
> sub mk_menu_element {
> my ($path, @files) = @_;
> print "<openbox_pipe_menu>";
> foreach $_ (@files) {
> my $length = length $_;
> my $last_c = substr $_, $length - 1, 1;
>
> if ($last_c eq "/") {
> print mk_dir_element($path, substr $_, 0, $length - 1);
> } elsif ($last_c eq "@") {
> print mk_sym_element($path, substr $_, 0, $length - 1);
> } else {
> print mk_file_element($path, $_);
> }
> }
> print "</openbox_pipe_menu>";
> }
>
> sub mk_dir_element {
> my ($path, $name) = @_;
>
> return "<menu id=\"$path/$name\" label=\"$name\" execute=\"browse $path/$name\" />";
> }
>
> sub mk_sym_element {
> my ($path, $name) = @_;
>
> return "<item label=\"$name\">"
> . "</item>";
> }
>
> sub mk_file_element {
> my ($path, $name) = @_;
>
> return "<item label=\"$name\">"
> . "view $name"
> . "</item>";
> }
More information about the openbox
mailing list