moz2fs

2017-05-15 05:55 UTC
  • Xyne

Metadata

Description:

Convert Mozilla (Firefox) bookmarks in JSON format to and from a filesystem hierarchy.

Latest Version:

2013.9.23.3

Source Code:

src/

Architecture:

  • any

Dependencies:

  • python3

Optional Dependencies:

  • unison: required by moz2fs-sync and moz2fs-profile-sync scripts

Arch Repositories:

  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]

AUR Page:

moz2fs

Arch Forum Thread:

170117

Tags:

About

I just wanted a way to synchronize a common subset of bookmarks across multiple accounts. So far I have not found anything that allows me to do this without some third-party server (and even them I'm not sure if anything really manages subsets).

This itch has been growing for over a year. I finally spent a little time deciding how to scratch it and came up with an admittedly suboptimal solution (i.e. not fully automatic) but one which should propagate changes the way I want.

moz2fs is a tool that converts a hierarchy of Mozilla (Firefox) bookmarks in a JSON file to a local hierarchy of files on disk. This makes it possible to synchronize bookmarks (including subdirectories) any which way you like using standard synchonization tools such as unison and rsync. You could sync them locally, over ssh(fs), dropbox, git, whatever.

Basically, it's a (not-so-)poor man's bookmark synchronization service. If you find something that achieves the same thing more easily, let me know.

Usage

Export the bookmarks in JSON format from Firefox: Bookmarks -> Show All Bookmarks -> Import and Backup -> Backup, then run

$ moz2fs <bookmark file> <some directory>

You now have a directory full of files representing your bookmarks. Sync it, back it up, whatever. To recreate the JSON bookmarks file (with modified contents), just run

$ moz2fs <directory> <some JSON file>

You can of course edit the files directly in the directory if you know what you are doing.

Helper Scripts

The package includes two helper scripts that use unison to synchronize subdirectories. moz2fs-sync will synchronize two JSON files, while moz2fs-profile-sync will synchronize the most recent bookmark backups in two different profile directories. Note that moz2fs-profile-sync is just a light wrapper around moz2fs-sync.

For example, I have a common set of Firefox bookmarks that I want to keep in sync across different system accounts. The bookmarks are in a directory names "common" in the bookmarks menu directory. To keep these in sync, I use a command such as the following:

moz2fs-profile-sync /path/to/profile/dir/1 path/to/profile/dir/2 'Bookmarks+Menu/common'

I can then easily include the changes from dropdown "Restore" menu in the Firefox bookmarks library interface.

Note that the subpath uses percent-escaped path components. If you are unsure of the exact path that you need to use, export the bookmarks.json file to a directory with moz2fs, and then look in there for the exact path.

Also note that these scripts are merely examples of what can be done with moz2fs. Modify them to suit your needs or create entirely different tools that work on the exported files (e.g. git-based syncrhonization tools).

Help Message

$ moz2fs --help

usage: moz2fs [-h] [-i INFO] [-s SEP] [-p] <input path> <output path>

Convert Mozilla (Firefox) bookmarks in JSON format to and from a filesystem
hierarchy.

positional arguments:
  <input path>          Either exported bookmarks in Mozilla's JSON format, or
                        a directory
  <output path>         Either exported bookmarks in Mozilla's JSON format, or
                        a directory.

optional arguments:
  -h, --help            show this help message and exit
  -i INFO, --info INFO  Name of file used to store directory information.
                        Default: .info.
  -s SEP, --sep SEP     Name of separator files. Default: separator.
  -p, --pretty          Prettify JSON when generating output file

If the input path is a JSON file then the output path must be a directory, and
vice versa.

CHANGELOG

2013-09-22

  • new grouping algorithm for re-inserting separators
  • added moz2fs-sync and moz2fs-profile-sync wrapper scripts
Contact
echo xyne.archlinux.ca | sed 's/\./@/'
Feeds
Blog News
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0