------------------------
This script shows all your GTK and Rox Filer bookmarks(see screenshot below).
Change the FILER variable at the top if you want them to open in something other than Rox when you click on them.
Put it in the menu, on a taskbar button, or wherever.
What should we call it? Pbookmark?
Code: Select all
#!/bin/sh
# Todo:
# Ability to edit the bookmarks? (or at least open the relevant file)
# Make code more elegant/faster
# Make filer an input argument - this could also enable it to be called e.g. instead of a drop-down bookmarks menu (e.g. pburn)
# Only show folders that exist?
# this would be consistent with the way the GTK open/save dialogue works,
# but not the rox bookmarks menu. And it might be GOOD to discover broken bookmarks.
# Which filer shall we use?
FILER="rox"
# Should we close the dialogue after calling the filer?
EXIT_ON_CLICK="no"
if [ "$EXIT_ON_CLICK" = "yes" ]
then ACTION="<action type=\"exit\">done</action>"
else ACTION=""
fi
if [ -d "$HOME/Desktop" ]
then DESKTOP="
<button xalign=\"0\" tooltip-text=\"$HOME\/Desktop\">
<label>Desktop</label>
<action>"$FILER" \"$HOME/Desktop\"</action>
$ACTION
</button>"
else DESKTOP=""
fi
# Start of dialogue
BOOKMARK_LIST="<window title=\"Open bookmarks:\" icon-name=\"gtk-directory\">
<hbox><frame GTK Bookmarks>
<button xalign=\"0\" tooltip-text=\"$HOME\">
<label>`basename \"$HOME\"`</label>
<action>"$FILER" \"$HOME\"</action>
$ACTION
</button>
$DESKTOP
<button xalign=\"0\" tooltip-text=\"\/\">
<label>Filesystem</label>
<action>"$FILER" /</action>
$ACTION
</button>"
# GTK bookmarks
if [ -r "$HOME/.gtk-bookmarks" ]; then
if [ "`grep -m1 file \"$HOME/.gtk-bookmarks\"`" = "" ]
then BOOKMARK_LIST="$BOOKMARK_LIST
<text>
<label>No bookmarks in $HOME/.gtk-bookmarks</label>
</text>"
else
# Buttons for each bookmarks
while read FILE_PATH FILE_NAME
do FILE_PATH=`echo ${FILE_PATH#file://}|sed 's/%20/ /g'`
BOOKMARK_LIST="$BOOKMARK_LIST
<button xalign=\"0\" tooltip-text=\"$FILE_PATH\">
<label>`[ -n "$FILE_NAME" ]&&echo $FILE_NAME||basename "$FILE_PATH"`</label>
<action>"$FILER" \"$FILE_PATH\"</action>
$ACTION
</button>"
done < "$HOME/.gtk-bookmarks"
fi
# NO GTK bookmarks file
else
BOOKMARK_LIST="$BOOKMARK_LIST
<text>
<label>$HOME/.gtk-bookmarks does not exist</label>
</text>"
fi
# Middle of dialogue
export BOOKMARK_LIST="$BOOKMARK_LIST
</frame>
<frame Rox Filer bookmarks>"
# Rox Filer bookmarks
if [ -r "$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml" ]; then
if [ "`grep -m1 title \"$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml\"`" = "" ]
then BOOKMARK_LIST="$BOOKMARK_LIST
<text>
<label>No bookmarks in $HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml</label>
</text>"
else
# Make sure each bookmark is on a new line
sed 's/></>\n</g' "$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml" >/dev/null
# Buttons for each bookmark
while read I
do if [ "`echo $I|grep title`" != "" ]
then FILE_PATH=`echo $I |cut -d \> -f 2|cut -d \< -f 1`
FILE_NAME=`echo $I |cut -d \" -f 2`
BOOKMARK_LIST="$BOOKMARK_LIST
<button xalign=\"0\" tooltip-text=\"$FILE_PATH\">
<label>$FILE_NAME</label>
<action>"$FILER" \"$FILE_PATH\"</action>
$ACTION
</button>"
fi
done < "$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml"
fi
# NO ROX Filer bookmarks
else
BOOKMARK_LIST="$BOOKMARK_LIST
<text>
<label>$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml does not exist</label>
</text>"
fi
# End of dialogue
export BOOKMARK_LIST="$BOOKMARK_LIST
</frame></hbox>
</window>"
gtkdialog3 -p BOOKMARK_LIST