You are not logged in.
Pages: 1
Hey, archbang community. I'm trying to change my openbox menu "places" to be based around "/home/matt/Directory" instead of "/home/matt". This seemed like an easy thing to fix , but i've opened my obpipemenu-places and tried editing it but found myself lost.
Here's my [the default] obpipemenu-places code, which I believe is what I should be changing.
#!/usr/bin/perl
# Recursively browse filesystem through openbox3 pipe menus
#### Usage: add
# <menu id="browse" label="Browse" execute="obpipemenu-places ~" />
# to your .config/openbox/menu.xml
#### CAVEAT ####
# This script was hacked on exclusively in stints between the hours of
# 4 and 5 in the morning. Quality may have suffered.
####
# Script by dircha from ob list on 05/17/04
# suggested improvements by John Russell on 05/17/04 implemented
# a year later by Kacper Wysocki.
# 05/30/05 - Kacper Wysocki
# - opens files with 'rox', which launches appropriate file handler
# - hidden directories now stay hidden
# - spaces, ampersands in dir- and filenames are escaped
# - newlines at each entry to make output a little readable
# 06/04/05 - Kacper Wysocki
# - use $0 for scriptname
# - use $ENV{'HOME'} as default path
# - now follows symlinks
use strict;
# Command to lauch files with
my $cmd = "pcmanfm";
my $path = $ARGV[0];
$path = $ENV{'HOME'} if $path eq "";
my @files = split /\n/, `ls -1p '$path'`;
mk_menu_element($path, @files);
sub mk_menu_element {
my ($path, @files) = @_;
print "<openbox_pipe_menu>\n";
# "Browse here..." lauches this dir
print "<item label=\"Browse here..\">".
"\n\t<action name=\"Execute\">".
"\n\t\t<execute>$cmd '$path'</execute>".
"\n\t</action>".
"\n</item>\n".
"<separator />";
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>\n";
}
sub mk_dir_element {
my ($path, $name) = @_;
# escape ampersand and space in pathnames
$path =~ s/&/&/g;
$name =~ s/&/&/g;
$path =~ s/ /\\ /g;
$name =~ s/ /\\ /g;
return "<menu id=\"$path/$name\" label=\"$name\" execute=\"$0 $path/$name\" />\n";
}
sub mk_sym_element {
my ($path, $name) = @_;
# escape ampersand in pathnames
$path =~ s/&/&/g;
$name =~ s/&/&/g;
# Follow symlinks instead of opening links in rox.
return "<menu id=\"$path/$name\" label=\"$name\" execute=\"$0 $path/$name\" />\n";
=cut
return "<item label=\"$name\">".
"\n\t<action name=\"Execute\">".
"\n\t\t<execute>$cmd '$path/$name'</execute>".
"\n\t</action>"
. "\n</item>\n";
=cut
}
sub mk_file_element {
my ($path, $name) = @_;
my $label = $name;
# escape ampersand in pathnames
$path =~ s/&/&/g;
$name =~ s/&/&/g;
return "<item label=\"$name\">".
"\n\t<action name=\"Execute\">".
"\n\t\t<execute>$cmd '$path/$name'</execute>".
"\n\t</action>"
. "\n</item>\n";
}If someone could help, a thousand internets to you ![]()
Last edited by matt0076 (2012-05-26 21:08:09)
Offline
Use code tags!
These are the important lines:
my $path = $ARGV[0];
$path = $ENV{'HOME'} if $path eq "";
$ARGV[0] is the parameter passed on the command line. If its blank, use your home directory (the environment variable).
So, all you have to do is pass the directory you want in the call to obpipemenu-places in the open box menus.
Offline
Use code tags!
These are the important lines:
my $path = $ARGV[0];
$path = $ENV{'HOME'} if $path eq "";$ARGV[0] is the parameter passed on the command line. If its blank, use your home directory (the environment variable).
So, all you have to do is pass the directory you want in the call to obpipemenu-places in the open box menus.
I'm not quote sure what a parameter passed on the command line means honestly, I've tried substituting the #ARG[0] for #ARG[/home/matt/Directory], as well as {'HOME'} for {'/home/matt/Directory'} but neither worked. What exactly did you mean?
Offline
Why not try
$path = "$ENV{'HOME'}/<directory>" if $path eq "";Change <directory> to whatever you need
Offline
Why not try
$path = "$ENV{'HOME'}/<directory>" if $path eq "";Change <directory> to whatever you need
didn't change a thing unfortunately, i tried like a hundred times
edit: I changed <directory> to /home/matt/Directory just confirming this is what you meant
Last edited by matt0076 (2012-05-27 00:51:18)
Offline
Read it again
$path = "$ENV{'HOME'}/Directory" if $path eq "";Am assuming you are running
$ENV{'HOME'}/home/user/directoryOffline
#!/usr/bin/perl
# Recursively browse filesystem through openbox3 pipe menus
#### Usage: add
# <menu id="browse" label="Browse" execute="obpipemenu-places ~" />
# to your .config/openbox/menu.xml
#### CAVEAT ####
# This script was hacked on exclusively in stints between the hours of
# 4 and 5 in the morning. Quality may have suffered.
####
# Script by dircha from ob list on 05/17/04
# suggested improvements by John Russell on 05/17/04 implemented
# a year later by Kacper Wysocki.
# 05/30/05 - Kacper Wysocki
# - opens files with 'rox', which launches appropriate file handler
# - hidden directories now stay hidden
# - spaces, ampersands in dir- and filenames are escaped
# - newlines at each entry to make output a little readable
# 06/04/05 - Kacper Wysocki
# - use $0 for scriptname
# - use $ENV{'HOME'}/home/matt/directory as default path
# - now follows symlinks
use strict;
# Command to lauch files with
my $cmd = "pcmanfm";
my $path = $ARGV[0];
$path = "$ENV{'HOME'}/Directory" if $path eq "";
my @files = split /\n/, `ls -1p '$path'`;
mk_menu_element($path, @files);
sub mk_menu_element {
my ($path, @files) = @_;
print "<openbox_pipe_menu>\n";
# "Browse here..." lauches this dir
print "<item label=\"Browse here..\">".
"\n\t<action name=\"Execute\">".
"\n\t\t<execute>$cmd '$path'</execute>".
"\n\t</action>".
"\n</item>\n".
"<separator />";
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>\n";
}
sub mk_dir_element {
my ($path, $name) = @_;
# escape ampersand and space in pathnames
$path =~ s/&/&/g;
$name =~ s/&/&/g;
$path =~ s/ /\\ /g;
$name =~ s/ /\\ /g;
return "<menu id=\"$path/$name\" label=\"$name\" execute=\"$0 $path/$name\" />\n";
}
sub mk_sym_element {
my ($path, $name) = @_;
# escape ampersand in pathnames
$path =~ s/&/&/g;
$name =~ s/&/&/g;
# Follow symlinks instead of opening links in rox.
return "<menu id=\"$path/$name\" label=\"$name\" execute=\"$0 $path/$name\" />\n";
=cut
return "<item label=\"$name\">".
"\n\t<action name=\"Execute\">".
"\n\t\t<execute>$cmd '$path/$name'</execute>".
"\n\t</action>"
. "\n</item>\n";
=cut
}
sub mk_file_element {
my ($path, $name) = @_;
my $label = $name;
# escape ampersand in pathnames
$path =~ s/&/&/g;
$name =~ s/&/&/g;
return "<item label=\"$name\">".
"\n\t<action name=\"Execute\">".
"\n\t\t<execute>$cmd '$path/$name'</execute>".
"\n\t</action>"
. "\n</item>\n";
}is what I have (which still isn't working), what did you mean by that last part?
oh, and thank you so much for your patience!
Last edited by matt0076 (2012-05-27 02:17:26)
Offline
You have edited the wrong line
It is the path line that needs to change
This is wrong
$ENV{'HOME'}/home/matt/directory It must read like this
$ENV{'HOME'}/directory Assuming that directory is in /home/matt change to where ever you need it
Offline
You should be editing your menu.xml file.
Easiest to mess with.
Honestly! The pipe menu tells you the usage in the 4th line.
Offline
You have edited the wrong line
It is the path line that needs to change
This is wrong
$ENV{'HOME'}/home/matt/directoryIt must read like this
$ENV{'HOME'}/directoryAssuming that directory is in /home/matt change to where ever you need it
are you talking about changing
my $path = $ARGV[0];to
my $path = $ENV{'HOME'}/directory ? because the line after that already reads
$path = "$ENV{'HOME'}/Directory" if $path eq "";and none of this is doing anything.
And yea, "directory" is in /home/matt.
You should be editing your menu.xml file.
Easiest to mess with.
Honestly! The pipe menu tells you the usage in the 4th line.
I tried playing around with it, but the menu.xml just runs pipemenu so it's not much use unless I want to rewrite the whole pipemenu
Offline
I tried a simple way and it worked for me:
1. Execute obmenu
2. Find the pipe menu of 'Palces'
3. In the box 'Execute', the last 'command' is '~/'
4. Change it to the disired folder, for exemple '~/Documents'
Fluent in Portuguese and Bad English
Offline
Offline
I tried a simple way and it worked for me:
1. Execute obmenu
2. Find the pipe menu of 'Palces'
3. In the box 'Execute', the last 'command' is '~/'
4. Change it to the disired folder, for exemple '~/Documents'
oh my god it worked I was trying that when I first started but it wouldn't let me edit it. Thank you so much. Also thank you Mr Green for sticking with me for so long!
Offline
Thanks goes to darktux for an even simpler answer..... have marked thread as solved
Welcome to ArchBang
Offline
Pages: 1