Topic: Dynamic places (pipe menu)
This script generates a menu similar to #!'s default Places menu but it isn't static, so there's no need to update it all the time if you rearrange your home directory structure a lot. By default it displays any directory in ~/ or /media
To use the menu save the script somewhere, let's say ~/.config/openbox/places.py and then make it executable ("chmod a+x ~/.config/openbox/places.py" in a terminal). Then add a line like this to your openbox menu.xml file:
<menu execute="~/.config/openbox/places.py" id="dynamic_places" label="Places"/>If you'd like the script to be useable system wide, then save it somewhere like /usr/bin instead of ~/.config/openbox and change the paths used in my examples to match. Thanks greenmanspirit and omns for this explanation, hope you don't mind me using it here where it's easy to find.
Look here for more information on pipe menus: http://icculus.org/openbox/index.php/He Pipe_menus
Important variables if you want to customise the generated menu:
manager - File manager which you want to use (nautilus, thunar, pcmanfm, rox-filer, konqueror, dolphin, etc).
dirs - The script lists and displays the subdirectories of these directories
ignore - Any item exactly matching an entry in this list will not be displayed
items - If you want to add a single directory entry to the menu you can do it here
Any suggestions on how to improve this would be appreciated.
Update:
* Removed trailing / characters from menu entries as suggested by Foomandoonian.
* The expanduser() function is now only called once, so that if you want to you can hardcode your home dir in its place and remove the "from os.path import expanduser" line. Doing this will make the script less portable, but should make it a tiny bit faster.
* The ignore list now accepts wildcards for pattern matching.
* - Matches everything
? - Matches any single character
[seq] - Matches any character in seq
[!seq] - Matches any character not in seq
* Added a variable for file manager, makes it easier to change if you don't use Thunar. Thanks for the idea kestrel.
* List of directories is now alphabetical. Thanks kestrel, can't believe I didn't think of this. It's currently set to preserve the order of directories you set in the dirs variable. Read the script comments if you want to change this.
Thanks for putting this in the pastebin corenominal. I'll try and keep these links current.
View the script here
The direct download link is: http://crunchbanglinux.org/pastebin/?dl=195
Last edited by kev (2009-02-26 02:37:47)