Page 1 of 3

ROX-Filer: Superfast bookmarks

Posted: Fri 06 Jun 2014, 07:18
by MochiMoppel
Very odd: ROX has a nice feature, but makes great efforts to hide it under the rug.

To start with, ROX hasn't even a proper name for it ("group selection"?). I call them speeddials. The user stumbles on them when he accidentally hits a single number key. Dressed-up as an error message he sees a short explanation how to use this feature. I assume most users close such messages before reading them.

The user manual hides the information in Chapter 4. ("Saving and restoring the selection"), after a somewhat unrelated explanation how to copy path names. What I regard as the main purpose is mentioned as a kind of side-effect:" Saving is also useful even if there is no selection, since it still saves the current directory." In other words: They are bookmarks. Shouldn't be confused though with the "official" slow and clumsy ROX bookmarks. These max. 10 bookmarks assigned to speeddial keys 0-9 are bookmarks on steroid. One keystroke is all it takes to open a bookmarked directory - can't get any faster than that. And as a bonus file selections in the directories are preserved.

However there is one thing that makes them hard to use: How to remember which key is assigned to which directory? There is no hint or list in the GUI. What good is it to be able access a directory in a split second when it takes half a minute to try all keys to find the right one?

To solve this problem I've created a little script that opens a list showing all key assignments. Though the list is clickable and can be used without ROX running, it is not meant as a replacement for the "real" thing used from within ROX.

Features:
- Script can be opened/closed with same desktop/keyboard shortcut. This makes it easy to shortly take a glimpse.
- Can be closed with Esc key or with Close button
- Can be used like a menu ("Keep window open" unchecked). Window will close after selecting a speeddial link.
- Can be used as launchpad ("Keep window open" checked). Window will stay open
- Links always open in new ROX window (vs. in ROX speeddial keys open directories always in current window)
- State of the "Keep window open" checkbox will be remembered (script updates itself. No extra config file needed)

Dependencies:
Requires gtkdialog4

Issues:
Let's see...
EDIT1: Changed <tree> attributes format to conventional syntax (see discussion below)
EDIT2: Now, 3 months later, the script has changed quite a bit and and progressed far beyond ROX speeddials. It now supports 5 different bookmark sources and goes beyond what I consider a HOWTO topic. I therefore moved the script to the Additional Software forum: http://www.murga-linux.com/puppy/viewtopic.php?t=95656
Image
The new SpeedDials script



Code: Select all

#!/bin/sh
# PURPOSE:          List all bookmarks currently assigned to keys 0~9 ("speeddials") in ROX
# PUPPY FORUM:      http://www.murga-linux.com/puppy/viewtopic.php?p=781563#781563        
# ROX Manual:       http://rox.sourceforge.net/Manual/Manual/Manual.html#id2502365
#============================================================
######## TOGGLE SCRIPT ON/OFF AND CHECK DEPENDENCIES
[ "`pidof $(basename $0)`" != "$$" ] && { pkill -f ROXKEY_DIALOG;exit; }
[ "`which gtkdialog4`" ]|| yaf-splash -text "This script requires gtkdialog4! May not work..." -close box -icon gtk-dialog-error
######## VARIABLES
WIN_HEIGHT=305 # <= Adjust this until vertical scrollbars vanish. 280 OK for Slacko, Precise 56 needs 300, Prec 57 305
WIN_WIDTH=600
CHECKBOXSTATUS=true
INPUT="/root/.config/rox.sourceforge.net/ROX-Filer/Groups.xml"
ICON='stock-id="gtk-jump-to"'
######## CREATE LIST OF ASSIGNED KEYS
TREE_ITEMS=$( 
tr -d "\n" < "$INPUT" |                             # Remove all linefeeds
sed 's/>[ \t]*</></g                                # Remove white space between tags
     s/<group name="/\n<item '$ICON'>/g' |          # Let all "<group name" tags start on new line, replace then with  <item...
sed '/^<item/!d                                     # Delete all lines that do not start with "<item"
/<\/item>/  s/"><directory>/ |[S]|/                 # Mark all lines with [S] containing </item> (=selection)
/<\/item>/! s/"><directory>/ |   |/                 # Mark all lines with blanks containing no </item> tag
            s/<\/directory>.*$/<\/item>/            # Replace everything after dir path with </item>
')
######## CREATE TOOLTIP IF ANY ITEM CONTAINS SELECTION GROUP
(( `grep -c "\[S\]" <<< "$TREE_ITEMS"` )) && TOOLTIP=$'[S]= Target contains file selection\nWhile in ROX press num.key to activate selection'
######## ADD LIST OF UNASSIGNED  KEYS
for c in {0..9};do ((`grep -c "^<item.*>$c" <<< "$TREE_ITEMS"`))||TREE_ITEMS="$TREE_ITEMS"$'\n'"<item>$c||--FREE--</item>" ;done
######## THE MEAT
export ROXKEY_DIALOG='
<window title="ROX speeddial keys 0-9" height-request="'$WIN_HEIGHT'" width-request="'$WIN_WIDTH'">
    <vbox>
        <tree exported-column="2" column-sizing="0|0|2" auto-sort="true" headers-visible="false" hover-selection="true" tooltip-text="'$TOOLTIP'" rules-hint="true" enable-search="false">
            <variable>vDIR</variable>
            <label>"Key|Selection|Directory"</label>
            '$TREE_ITEMS'
            <action>[ -d "$vDIR" ] && { rox -d "$vDIR"; [ $vCBOX = "false" ] && pkill -f ROXKEY_DIALOG ;}</action>
            <action signal="button-release-event">[ -d "$vDIR" ] && { rox -d "$vDIR"; [ $vCBOX = "false" ] && pkill -f ROXKEY_DIALOG ;}</action>
        </tree>
        <hbox>
            <checkbox>
                <label>"Keep window open"</label>
                <default>'$CHECKBOXSTATUS'</default>
                <variable>vCBOX</variable>
                <action>sed -i "0,/CHECKBOXSTATUS=.*/  s//CHECKBOXSTATUS=$vCBOX/" '"$0"'</action>
            </checkbox>
            <hbox space-expand="true" space-fill="true"><text><label>"                                                    "</label></text></hbox>
            <button><input file stock="gtk-close"></input><label>"    Close    "</label></button>
        </hbox>
    </vbox>
    <action signal="key-press-event">[ $KEY_VAL = "0xff1b" ]    && pkill -f ROXKEY_DIALOG</action>
</window>
'
export ROXKEY_DIALOG=$(echo "$ROXKEY_DIALOG" | sed 's/#[#~].*$//') # Strip comments
gtkdialog  --class=ROXKEY_DIALOG --program=ROXKEY_DIALOG

Posted: Fri 06 Jun 2014, 20:27
by Keef
I'd always wondered what that meant, and yes, I never really read what it said either. Thanks.

Posted: Fri 06 Jun 2014, 22:47
by Puppus Dogfellow
i have gtdialog version 0.8.3 (a long way away from 4 it seems) so no surprise the script didn't work for me, but this is a cool feature. i've never come across that error box before and was completely unaware this even existed. thanks for the heads up, Mochi. very convenient.

Posted: Fri 06 Jun 2014, 23:36
by RSH
i have gtdialog version 0.8.3 (a long way away from 4 it seems)
No.

Everything from gtkdialog 0.8.0 is gtkdialog 4 (gtkdialog4)

Search the forum for "gtkdialog version 0.8.4 r514" to get the newest version.

Note: there are different versions for Lucid, Precise and Slacko.

If you are using an older puppy, gtkdialog might be a symbolic link to gtkdialog3 - check this.

Posted: Fri 06 Jun 2014, 23:42
by Puppus Dogfellow
RSH wrote:
i have gtdialog version 0.8.3 (a long way away from 4 it seems)
No.

Everything from gtkdialog 0.8.0 is gtkdialog 4 (gtkdialog4)

Search the forum for "gtkdialog version 0.8.4 r514" to get the newest version.

Note: there are different versions for Lucid, Precise and Slacko.

If you are using an older puppy, gtkdialog might be a symbolic link to gtkdialog3 - check this.
so the script should have run?

(it was cool to get to its location with a number press...)


RSH, how do i check? i typed "which gtkdialog" and the terminal just kind of ignored it. (gave me a new # line).

...

on a side note, a weird glitch i cannot now reproduce: the search results for "gtkdialog version 0.8.4 r514" gave me three pages for topic, 68 for posts, but when i tried to move off page one, i got sent back to the search box page. didn't matter if i pressed next or page number. never happened before and is not happening now, but figured i'd mention it.

Posted: Sat 07 Jun 2014, 00:02
by RSH
The latest gtkdialog4.
The script should definitely run with this version installed.

Posted: Sat 07 Jun 2014, 00:09
by Puppus Dogfellow
RSH wrote:The latest gtkdialog4.
The script should definitely run with this version installed.
nope, but thanks for finding it for me.

(installed the precise pet on a 5.5. frugal on an SD card).

Posted: Sat 07 Jun 2014, 00:15
by MochiMoppel
Puppus Dogfellow wrote:so the script should have run?
Yes. I tested with Precise 5.6 (uses 0.8.3, located in /usr/bin) and Slacko 5.6 (uses 0.8.4, located in /usr/sbin).
Did you copy correctly?

Posted: Sat 07 Jun 2014, 00:16
by RSH
Tested and didn't work here also.

The cause is:

Code: Select all

       <tree
            exported-column="2"
            column-sizing="0|0|2"
            auto-sort="true"
            headers-visible="false"
            hover-selection="true" 
            tooltip-text="'$TOOLTIP'"
            rules-hint="true"
            enable-search="false"
        >
 
This needs to be a single line:

Code: Select all

        <tree exported-column="2" column-sizing="0|0|2" auto-sort="true" headers-visible="false" hover-selection="true" tooltip-text="'$TOOLTIP'" rules-hint="true" enable-search="false">
Then it works

Posted: Sat 07 Jun 2014, 00:29
by MochiMoppel
That's funny. I know it should be a single line, so I was surprised to find that splitting the line into multiline chunks, which makes the code much more readable and maintainable, also works - at least for me. I just did this on a pristine Precise 5.6. Copied the code from the post into a new script template...and it worked! What do I have that others don't ? :lol:

Anyway, I edited the code.

Posted: Sat 07 Jun 2014, 02:46
by Puppus Dogfellow
edited code works (confirmed in precise 5.6.1; the earlier version failed to run on 5.5 and 5.7 as well as this installation).

thanks for this--it'll help proliferate windows for the other script to close.

:)

[now confirmed for 5.5]

Posted: Sat 07 Jun 2014, 04:17
by musher0
Hello, mochimoppel.

Before I "officially" thank you ;), I need to know where and how to populate the entries of this
"speed dial". As it is, it is a good piece of code, no doubt, but it is useless! :)

"Un-official" ;) thanks in advance.

musher0

Posted: Sat 07 Jun 2014, 04:43
by MochiMoppel
If you've never used "groups" before, i.e. you never pushed Ctrl+<number>, then ROX hasn't yet created a file /root/.config/rox.sourceforge.net/ROX-Filer/Groups.xml. If you run the script before Groups.xml exists, all the slots will show --FREE--. Create some speeddials and run the script again. :wink:

Posted: Sat 07 Jun 2014, 05:14
by musher0
I can now issue "official" thanks! ;)

Posted: Sat 07 Jun 2014, 07:06
by MochiMoppel
I humbly offer my official "You're welcome". But please stop editing Groups.xml manually. Look closely at your screenshot and find the mistake...

Re: ROX-Filer: Superfast bookmarks

Posted: Sat 07 Jun 2014, 07:30
by neerajkolte
Many many Thanks MochiMoppel.

Any one has an idea or theory about why this was hidden by ROX.

Posted: Sat 07 Jun 2014, 12:33
by musher0
MochiMoppel wrote:I humbly offer my official "You're welcome". But please stop editing Groups.xml manually. Look closely at your screenshot and find the mistake...
Ah, yes, a typo! :) Sorry about that!
But please tell me how can I edit Groups.xml other than manually?
Thanks in advance.

Posted: Sat 07 Jun 2014, 13:00
by MochiMoppel
Groups.xml is created and managed by ROX. You shouldn't edit it.

Posted: Sat 07 Jun 2014, 13:10
by musher0
MochiMoppel wrote:Groups.xml is created and managed by ROX. You shouldn't edit it.
Hello, MochiMoppel.

That's not an answer. Or it is, an ethical or normative, answer. But not a practical one.
You're telling me what not to do, not how to do it properly.

Ok. In communications theory, if you get the wrong answer, it's that you asked the
wrong question.

So I'll put my question another way: could you please tell me how you,
not somebody else, insert the folders in the Groups.xml file?

Thanks in advance.

musher0

Posted: Sat 07 Jun 2014, 13:56
by Keef
See my screenshot. Couldn't be much simpler.