2 # Recursively browse filesystem through openbox3 pipe menus
4 # <menu id="browse" label="Browse" execute="obpipemenu-places ~" />
5 # to your .config/openbox/menu.xml
7 # This script was hacked on exclusively in stints between the hours of
8 # 4 and 5 in the morning. Quality may have suffered.
10 # Script by dircha from ob list on 05/17/04
11 # suggested improvements by John Russell on 05/17/04 implemented
12 # a year later by Kacper Wysocki.
13 # 05/30/05 - Kacper Wysocki
14 # - opens files with 'rox', which launches appropriate file handler
15 # - hidden directories now stay hidden
16 # - spaces, ampersands in dir- and filenames are escaped
17 # - newlines at each entry to make output a little readable
18 # 06/04/05 - Kacper Wysocki
19 # - use $0 for scriptname
20 # - use $ENV{'HOME'} as default path
21 # - now follows symlinks
25 # Command to lauch files with
29 $path = "$ENV{'HOME'}" if $path eq "";
30 my @files = split /\n/, `ls -1p '$path'`;
31 mk_menu_element($path, @files);
34 my ($path, @files) = @_;
36 print "<openbox_pipe_menu>\n";
38 # "Browse here..." lauches this dir
39 print "<item label=\"Browse here..\">".
40 "\n\t<action name=\"Execute\">".
41 "\n\t\t<execute>$cmd '$path'</execute>".
47 my $length = length $_;
48 my $last_c = substr $_, $length - 1, 1;
51 print mk_dir_element($path, substr $_, 0, $length - 1);
52 } elsif ($last_c eq "@") {
53 print mk_sym_element($path, substr $_, 0, $length - 1);
55 print mk_file_element($path, $_);
58 print "</openbox_pipe_menu>\n";
62 my ($path, $name) = @_;
63 # escape ampersand and space in pathnames
69 return "<menu id=\"$path/$name\" label=\"$name\" execute=\"$0 $path/$name\" />\n";
73 my ($path, $name) = @_;
74 # escape ampersand in pathnames
78 # Follow symlinks instead of opening links in rox.
79 return "<menu id=\"$path/$name\" label=\"$name\" execute=\"$0 $path/$name\" />\n";
81 return "<item label=\"$name\">".
82 "\n\t<action name=\"Execute\">".
83 "\n\t\t<execute>$cmd '$path/$name'</execute>".
90 my ($path, $name) = @_;
92 # escape ampersand in pathnames
96 return "<item label=\"$name\">".
97 "\n\t<action name=\"Execute\">".
98 "\n\t\t<execute>$cmd '$path/$name'</execute>".