Bookmark Twins

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Bookmark Twins

#1 Post by musher0 »

Hello, people.

I believe this has been asked here:
http://murga-linux.com/puppy/viewtopic.php?t=93637
I created this separate thread because this function is not per se related to jwm.

The two scripts do the reverse of each other. They go in /root/my-applications/bin.

You may want to drop a link of one in your ~/Startup folder, so your gtk and ROX
bookmarks are always "twinned". Use only one link in Startup, or they will cancel
each other out.

For the rest, I think the scripts are pretty well commented.
Any comments? Drop a line here! I'll see what I can do.

BFN.

musher0

~~~~~~~~~~~~

Code: Select all

#!/bin/sh
# $MBINS/rox-Bkmrks2gtk-bkmrks.sh
# Purpose: have ~/.gtk-bookmarks mirror
# /root/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml.
#
# Companion file to $MBINS/gtk-bkmrks2rox-Bkmrks.sh
# For Puppy_Dogfellow and all fine Puppyists out there!
#
# # (c) Christian L'Écuyer (alias / aka musher0), Gatineau (Qc), Canada, 
 # 27 mai / May 27, 2014. Tous droits réservés / All rights reserved.
#### 
# Backup
cp -f --backup ~/.gtk-bookmarks ~/.gtk-bookmarks.bckp

# Action
awk -F">" '{print $2}' ~/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml | sort -t "/" -k 2 | awk -F"<" '$1 != "" {print "file:\/\/"$1}' > ~/.gtk-bookmarks

# Notes
# - The < --backup > setting creates a 2nd backup after the 1st run.
# - The result is sorted according to the first-level folder name
# ( sort -t "/" -k 2 ), but you may have repetitions in the gtk window 
# when opening or saving a file because gtk reads from the last field.
~~~~~~~~~~~~~

Code: Select all

#!/bin/sh
# $MBINS/gtk-bkmrks2rox-Bkmrks.sh
# Purpose: have ~/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml
# mirror ~/.gtk-bookmarks.
#
# Companion file to $MBINS/rox-Bkmrks2gtk-bkmrks.sh
# Dependency: replaceit.
#
# For Puppy_Dogfellow and all fine Puppyists out there!
#
# # (c) Christian L'Écuyer (alias / aka musher0), Gatineau (Qc), Canada, 
 # 27 mai / May 27, 2014. Tous droits réservés / All rights reserved.
####
# Preparation
cd /root/.config/rox.sourceforge.net/ROX-Filer/

# Backups
cp -f --backup Bookmarks.xml Bookmarks.xml.bckp
cp -f ~/.gtk-bookmarks ~/gtk-temp

# Action
replaceit --input=/root/gtk-temp "file:///" "/"
sleep 0.5
for i in `cat /root/gtk-temp`
do 
	echo "  <bookmark title=\"$i\">$i</bookmark>" >> Bookmarks.temp
done
#
# Of course, this only repeats the folder name twice...
# It'll be up to you to personalize the names in the ROX-Filer.
#
# To do so, click on the "arrow-goldenball" icon, and then on "Edit 
# bookmarks". You edit the 2nd column, marked "Title", by double- 
# clicking in the desired field, and then writing something.)
#
echo "<?xml version=\"1.0\"?>" > Bookmarks.tmp
echo "<bookmarks>" >> Bookmarks.tmp
cat Bookmarks.temp >> Bookmarks.tmp
echo "</bookmarks>" >> Bookmarks.tmp
sleep 0.1s

# Clean-up
rm -f Bookmarks.temp
rm -f ~/gtk-temp
mv -f Bookmarks.tmp Bookmarks.xml

# Note
# - The < --backup > setting creates a 2nd backup after the 1st run.
Attachments
bookmark-twins.zip
(1.83 KiB) Downloaded 146 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

What does this do? What would I use it for? :?

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#3 Post by Puppus Dogfellow »

so this replaces your Rox bookmarks with your GTK bookmarks and vice versa? i'm not sure i would want that unless i have an unpopulated list (like on a relatively new installation). i always fill in the rox stuff first chance i get (add to bookmarks from any filer window is simply a more common encounter than when the program happens to be using gtk and gives you the + - in the popup that occurs at saves and openings) and the gtk stuff when the opportunity presents itself. because of the bookmarks script i use (from disciple, which gives both lists at the same time), i pared it down for less redundancy somewhat, though some are still essential to have on both, i think...

my name is sort of in the comments, but i'm not sure i'd want to overwrite one with the other. on a fresh install, i think rox over to gtk isn't a bad idea though.

am i off on what it does? is this a separate thing that pops up or just an easy way to populate the lists?

can it be modded to make a gtk bookmarks list on the jwm menu? (sorry, i know you are moving away from JWM dependency in your projects, but i figured i'd ask).

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#4 Post by musher0 »

Hello, guys.

These scripts harmonize the ROX-Filer bookmarks list with gtk-bookmarks list.
In the attached picture, I have drawn lines for the correspondences.
The ROX-filer bookmarks are on the left, and the gtk bookmarks are on the right.

~~~~~~~~~~
@Flash
The gtk bookmarks are those that appear in the panel when you want to open or save
a file, in geany, for example. You can add some bookmarks in that panel by
highlighting a folder in the right part, and clicking on the + icon at the bottom left.

The ROX-Filer bookmarks are those that you can define in ROX (the arrow-golden_
globe icon) as you browse through your directory tree.

Let's say you go to a folder and you want to bookmark it for easy access later. How
can you do that? You click on the arrow-globe icon at the top of the ROX-Filer window,
then you click "add". The name of the folder is added automatically at the bottom of the list.

~~~~~~~~~~
@ Puppus_D.
I'm sorry if this not what you meant by "making the bookmarks available" in the
other thread.

But if you take a minute to think about it, this is the logical complement to adding
bookmarks in the jwm menu. With these scripts and mochimopel's contribution in
the other thread, you have the possibility to have identical bookmarks in the ROX
window, in the GTK panel and in the jwm menu.

As to your other comment, I also find it more natural to mirror the ROX-Filer
bookmarks to the gtk bookmarks. But some people may think or be accusomed to
doing things the other way around, so I created a second script that mirrors the gtk
bookmarks to the ROX bookmarks. Choice is good, no?! :)

~~~~~~~~~~
In conclusion, those bookmarks are what's known as "accelerators" or "facilitators".
They speed up your access to your desired folders.

I created these scripts because having both of them refer to the same folders was less
confusing for me. It is my hope that some other users will find these mirroring scripts
useful as well.

I hope this post clarifies the subject a bit. Don't be afraid to ask more questions if it
doesn't!

BFN.

musher0
Attachments
ROX_and_gtk_bookmarks_are_harmonized.jpg
ROX bookmarks are at the left, gtk bookmarks are at the left.
(46.18 KiB) Downloaded 160 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#5 Post by Puppus Dogfellow »

musher, it adds one to the other or it overwrites one with the other?

if the former, then of course it's good--gain with no loss, which is what i (mistakenly) feared it did.

:D

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#6 Post by musher0 »

Hello again, Puppus.

Well, the scripts make backups of the target files. So no worries.

The script doesn't add anything to the existing file, it replaces it. Boom. Replace.
Hence the backups: if you don't like the results, just squish the file that has just been
created with the old file (the old file has the extension .bckp). And you're back with
the file you're used to.

The adding is done manually by you, the user, as you browse through your folders,
either while you are in the ROX-Filer, or while you are in the gtk Save / Open panel.


For example, say that you have added ten folders that you use a lot, to the folders
list in ROX-Filer. Now you want to have the same folders in your gtk bookmarks. Use
the rox-bkmrks2gtk-bkmrks.sh script and it's done: your gtk bookmarks are now
aligned with the ROX bookmarks.

The scripts do not invent any new locations for you. They use the bookmarks that you
yourself have already put in the lists manually.

(Maybe my example is confusing because, as a developer, I use a lot of bookmarks to
go here and there quickly in the folder tree. I realize that the ordinary user will have
just a few bookmarks, if any.)

I hope this helps.

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#7 Post by Puppus Dogfellow »

musher0 wrote: [...]

(Maybe my example is confusing because, as a developer, I use a lot of bookmarks to
go here and there quickly in the folder tree. I realize that the ordinary user will have
just a few bookmarks, if any.)

I hope this helps.

BFN.

musher0

i've my share, too, musher:

Image



:roll: :lol:

(to be fair to disciple and his script, the screen shot, because i dragged my feet about the desktop, registered just before the path popup appeared.)

while a useful script, yours may render some other things i find useful less so, which is why i asked about a separate jwm menu entry for the gtk stuff...

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#8 Post by musher0 »

My, you've got more bookmarks than I do! :shock: 8) :D
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post by musher0 »

Besides, I find disciple's approach visually cumbersome. And I hate buttons!
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#10 Post by Puppus Dogfellow »

musher0 wrote:Besides, I find disciple's approach visually cumbersome. And I hate buttons!
to each his own but it is only on the screen for as long as you stare at it wondering where to go (unless you have it set to stay on after an entry is selected).
musher0 wrote:My, you've got more bookmarks than I do! :shock: 8) :D
yeah, i tend to have them pile up. i do do some gardening from time to time, though it does seem that i plant more than i prune.

since my gtk version is too old for scroll bars (apparently and from what i gleaned), i should probably change the font size to fit more of those objectionable rectangles on the screen--it's a 26 inch tv i sit 18 inches from when at that machine...they're some unnecessarily big buttons.

:)

Post Reply