Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Obpiper: Pipe menu generator for Openbox
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
lazarusrat
Guru
Guru


Joined: 17 Jul 2002
Posts: 305
Location: Lafayette, IN

PostPosted: Sat Sep 02, 2006 11:31 pm    Post subject: Obpiper: Pipe menu generator for Openbox Reply with quote

Here is a rather large Perl script I wrote to generate pipe menus for Openbox 3+:

obpiper-1.04.tgz

There are two basic modes of use: Directory and Find-Command. There's POD in the script, but I think it's best explained with examples. :)

For a Directory example, here's what I use to make a menu to open any of the .txt and .log files (-e 'txt|log') in my ~/logs directory (-d '~/mlogs') with nedit (-c 'nedit'), recursively (-r):
Code:
obpiper -d '~/mlogs' -e 'txt|log' -c 'nedit' -r

So in my OB menu.xml there's an entry:
Code:
<menu id="mlogs-menu" label="Logs" execute="obpiper -d '~/mlogs' -e 'txt|log' -c 'nedit' -r" />

Directory mode excludes hidden files and directories by default, but they can be included with -i. Directories with no files matching the extensions (-e) are not included. If you want to include files with no extensions, add a pipe to the very beginning of the extension list (-e '|txt|log').

For the Find-Command example, here's a "little" script I wrote to list all the partitions listed as noauto in /etc/fstab:
Code:
grep -e '^\/.*noauto.*' /etc/fstab | perl -p -e 'chomp; s/\s+/ /g; s/$/\n/' | cut -d ' ' -f 2

Now to get a pipe menu to mount those, I use:
Code:
obpiper -c 'mount' -f "grep -e '^\/.*noauto.*' /etc/fstab | perl -p -e 'chomp; s/\s+/ /g; s/$/\n/' | cut -d ' ' -f 2"

Since I don't want to have to type all that into Openbox' menu.xml, I save those settings to a file (the -s switch at the end):
Code:
obpiper -c '/bin/mount' -f "grep -e '^\/.*noauto.*' /etc/fstab | perl -p -e 'chomp; s/\s+/ /g; s/$/\n/' | cut -d ' ' -f 2" -s '~/.openbox/config/mount.pipe'

Now I can load that settings file with -l, so all my menu.xml needs is:
Code:
<menu id="mount-menu" label="Mount" execute="obpiper -l ~/.config/openbox/mount.pipe" />

For a lighter version of that, that doesn't pick up /boot, but is a little easier to read:
Code:
obpiper -c /bin/mount -f 'ls /mnt'


I've only tested this on my own machine, so feel free to kick the tires and let me know if you encounter any bugs. :)

Two caveats I can think of right off the bat. First, in that the menu entries generated by the script are enclosed in single quotes. So if the command you give with the -c option (the command you want to run on the files the script finds) has single quotes, Openbox is likely going to choke on it, as it won't be valid XML. I might get around to working around that soon, I might not.

Second, the -f option just runs whatever command you give it without regard for life or limb. Make sure you don't put anything dangerous in there, and don't run commands you find elsewhere unless you can tell what they do.
_________________
obpiper: pipe menu generator for openbox
obtheme: pipe menu to switch openbox themes
Back to top
View user's profile Send private message
lazarusrat
Guru
Guru


Joined: 17 Jul 2002
Posts: 305
Location: Lafayette, IN

PostPosted: Thu Sep 07, 2006 12:59 am    Post subject: Reply with quote

Only bumping this for people who may already be using one of the versions posted here. I've updated it quite a bit, largely bug fixes, but a few new features as well (two modes of recursion in Find-Command mode). From now on I'll just edit the main post with a link to the current .tgz if I make any more changes. But for now, I don't see too many more changes happening unless someone finds some bugs.
_________________
obpiper: pipe menu generator for openbox
obtheme: pipe menu to switch openbox themes
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum