How to Sync your Opera 12 bookmarks, history, and mail using Dropbox

opera-2004

In this tutorial I’m going to show you how to sync your Opera 12 bookmarks, history, and mail using Dropbox. It involves doing some annoying things to your files (symlinking, etc.) so that Dropbox does the hard work of keeping your bookmarks, mail, history, etc., updated across your various computers. On the bright side, you should only have to do it once.

This post assumes you are a Dropbox user, and you have Opera 12 installed on multiple computers. It doesn’t cover mobile devices, since there was never a mobile version of Opera’s desktop browser.

These instructions work for Linux and the Mac. I would like to do this on my Windows laptop too, but I haven’t been able to get it to work yet. I can’t seem to get Opera to use a link to a folder as if it’s a real folder. If someone knows how to do this, feel free to leave a comment.

One more thing:

OPERA 12 IS OLD AND UNSUPPORTED SOFTWARE THAT PROBABLY HAS SECURITY VULNERABILITIES. YOU ALMOST CERTAINLY SHOULD NOT USE IT. OPERA SOFTWARE ASA DOESN’T WANT YOU TO USE IT. THE ONLY REASON I FEEL “SAFE” USING OPERA 12 IS BECAUSE I BLACKLIST ALL JAVASCRIPT BY DEFAULT AND USE MODERN UP-TO-DATE BROWSERS FOR ONLINE BANKING, INTERACTIVE WEB APPS, ETC.

OK, now that I’ve shouted a disclaimer at you, let’s do this.

A note on using Dropbox

You may have some concerns about Dropbox’s file synchronization messing up your stuff. For what it’s worth, I’ve been doing this for several months now, and have found that for the most part it just works. In my experience Dropbox basically just handles file updates with no drama.

If it does encounter drama (e.g., finds that it can’t handle a conflict between two different versions of a file), it creates a new version of the file called something like “autosave\ (glamdring2's\ conflicted\ copy\ 2016-02-27).win“, where “glamdring2” is the name of the computer with the conflicted file.

This means you can manually fix things if you have to, but you basically never have to as long as you take care to shut down Opera on computer A and wait until Dropbox is fully synced to start Opera on computer B. This normally takes just a few seconds.

Remember, you should not be doing this with your only copy of your Opera folder. You need to keep regular backups of your Opera folder, and syncing is not a backup.

Step 1. Find your Opera folder

Because Opera is a pretty sane app, it stores all of its junk in one folder (with the exception of the Mac version, about which more below).

Depending on your platform, you’ll find the folder in different places. For more information about where your version of Opera stores its files, see Files used by Opera.

On Linux, it’s easy. Everything is in

~/.opera

On Mac, there is a slight wrinkle. Opera 12 stores your Opera prefs and bookmarks in one place, and your mail in another. This means we need to get them all together in one place so we can sync them with Dropbox.

According to the link above, here’s where your bookmarks, history, etc. are stored if you’re a Mac user:

~/Library/Opera

And it stores your mail in:

~/Library/Application Support/Opera

This is because (according to the docs), user data of “significant size” should go into this other random folder. Um, okay.

In any case, in order to get your Mac install of Opera 12 to work with the actual mail you’ll be syncing in your Dropbox folder, you need to do some goofy stuff with symbolic links, namely:

$ cd ~/Library/Application Support/Opera/
$ mv mail ~/Library/Opera
$ ln -s ~/Library/Opera/mail .

Now everything should all be in ~/Library/Opera (Mac) or ~/.opera (Linux).

Step 2. Copy your Opera folder into Dropbox

Now that we have all of our Opera things in one place, let’s copy the single Opera folder into Dropbox and link it back to wherever your Opera app is expecting the folder to be. On Linux you would do something like this in your terminal – note that Opera should not be running when you do this:

$ mv ~/.opera ~/.opera.bak # Minimal backup copy, you should really do more
$ cp -R ~/.opera.bak ~/Dropbox/opera_config

For Mac it’s pretty similar:

$ mv ~/Library/Support/Opera ~/Library/Support/Opera.bak # Minimal backup copy
$ cp -R ~/Library/Opera.bak ~/Dropbox/opera_config

In English, this:

  • Makes a backup of your Opera folder so if something gets messed up, you can put things back the way they were
  • Copies the backup into your Dropbox folder, where it can be synced across all of your machines

Step 3. Link the folder from Dropbox back to where the app wants it

Now we need to make it look to the Opera 12 app like everything is totally normal. We’ll do that by creating a link from the folder sitting in Dropbox back to where the app expects it to be.

Again, I’m really happy to hear from people about how to do this on Windows. Thus far all of my attempts have failed, and the way Windows handles what it calls “links” seems basically Crazytown. But it’s probably just that I don’t understand them well enough.

Anyway, here’s how you do the linking on Linux:

$ ln -s ~/Dropbox/opera_config ~/.opera

And on Mac:

$ ln -s ~/Dropbox/opera_config ~/Library/Opera

Step 4. Profit?

At this point you should be syncing your mail, bookmarks, history, and sessions across computers. When you shut down Opera 12 on your work machine (a Mac laptop), you can open up Opera 12 on your home workstation running Linux and be in the same session, looking at the same tabs and emails. Everything should just magically work.

If it doesn’t, please let me know in the comments and I’ll try to help.

Advertisements

Editing Chrome Textareas with Edwin

edwin-editing-textarea

In this post, I’ll describe how to edit Chrome textareas with the Edwin text editor that comes built-in with MIT/GNU Scheme.

If you just want to see the end result, see the screenshot and video at the end of this post.

These instructions will also work with recent releases of the Opera browser (since the newer Chromium-based versions can run Chrome plugins). They may also work at some point with Firefox, when Mozilla implements the new WebExtensions API.

At a high level, the steps to edit Chrome textareas with Edwin are:

  1. Install a browser add-on
  2. Customize Edwin with a few hacks
  3. Write a shell script to make it easy to launch Edwin from the command line
  4. Run a local “edit server” that interacts with the browser add-on and launches Edwin

On This Page

Install the ‘Edit with Emacs’ add-on

Install the Edit with Emacs add-on from the Chrome Web Store.

Load some Edwin hacks

The default way to open Edwin is to run

$ mit-scheme --edit

This just launches an Edwin editor window. From there, you need to manually open files and edit them.

What we need is a way to launch Edwin and open a specific file automatically. Most editors you are familiar with already do this, e.g.,

$ vim /tmp/foo.txt
$ emacsclient /tmp/bar.txt

To be able to launch Edwin in this way, we need to hack a few procedures in the file editor.scm in the MIT/GNU Scheme source and load them from the Edwin init file. We’ll tackle each of these tasks separately below.

Hacking editor.scm

To get Edwin to open a file on startup, we need to tweak three procedures in editor.scm to accept and/or pass around filename arguments:

  • CREATE-EDITOR
  • STANDARD-EDITOR-INITIALIZATION
  • EDIT

Here’s the code; you can just paste it into a file somewhere. For the purposes of this post we’ll call it open-edwin-on-file.scm:

;;;; open-edwin-on-file.scm -- Rich's hacks to open Edwin on a specific file.

;;; These (minor) changes are all to the file `editor.scm'. They are
;;; all that is needed to allow Edwin to be opened on a specific file
;;; by adding a `filename' argument to the EDIT procedure.

(define (create-editor file . args)
  (let ((args
     (if (null? args)
         create-editor-args
         (begin
           (set! create-editor-args args)
           args)))
        (filename (if (file-exists? file)
                      file
                      #f)))
    (reset-editor)
    (event-distributor/invoke! editor-initializations)
    (set! edwin-editor
      (make-editor "Edwin"
               (let ((name (and (not (null? args)) (car args))))
             (if name
                 (let ((type (name->display-type name)))
                   (if (not type)
                   (error "Unknown display type name:" name))
                   (if (not (display-type/available? type))
                   (error "Requested display type unavailable:"
                      type))
                   type)
                 (default-display-type '())))
               (if (null? args) '() (cdr args))))
    (set! edwin-initialization
      (lambda ()
        (set! edwin-initialization #f)
        (if filename
                (standard-editor-initialization filename)
                (standard-editor-initialization))
    (set! edwin-continuation #f)
    unspecific))))

(define (standard-editor-initialization #!optional filename)
  (with-editor-interrupts-disabled
   (lambda ()
     (if (and (not init-file-loaded?)
          (not inhibit-editor-init-file?))
     (begin
       (let ((filename (os/init-file-name)))
         (if (file-exists? filename)
         (load-edwin-file filename '(EDWIN) #t)))
       (set! init-file-loaded? #t)
       unspecific))))
  (let ((buffer (find-buffer initial-buffer-name))
        (filename (if (not (default-object? filename))
                      ((ref-command find-file) filename)
                      #f)))
    (if (and buffer
         (not inhibit-initial-inferior-repl?))
    (start-inferior-repl!
     buffer
     (nearest-repl/environment)
     (and (not (ref-variable inhibit-startup-message))
          (cmdl-message/append
           (cmdl-message/active
        (lambda (port)
          (identify-world port)
          (newline port)))
           (cmdl-message/strings
        "You are in an interaction window of the Edwin editor."
                "Type `C-h' for help, or `C-h t' for a tutorial."
                "`C-h m' will describe some commands."
                "`C-h' means: hold down the Ctrl key and type `h'.")))))))

(define (edit file . args)
  (call-with-current-continuation
   (lambda (continuation)
     (cond (within-editor?
        (error "edwin: Editor already running"))
       ((not edwin-editor)
        (apply create-editor file args))
       ((not (null? args))
        (error "edwin: Arguments ignored when re-entering editor" args))
       (edwin-continuation
        => (lambda (restart)
         (set! edwin-continuation #f)
         (within-continuation restart
           (lambda ()
             (set! editor-abort continuation)
             unspecific)))))
     (fluid-let ((editor-abort continuation)
         (current-editor edwin-editor)
         (within-editor? #t)
         (editor-thread (current-thread))
         (editor-thread-root-continuation)
         (editor-initial-threads '())
         (inferior-thread-changes? #f)
         (inferior-threads '())
         (recursive-edit-continuation #f)
         (recursive-edit-level 0))
       (editor-grab-display edwin-editor
     (lambda (with-editor-ungrabbed operations)
       (let ((message (cmdl-message/null)))
         (cmdl/start
          (make-cmdl
           (nearest-cmdl)
           dummy-i/o-port
           (lambda (cmdl)
         cmdl       ;ignore
         (bind-condition-handler (list condition-type:error)
             internal-error-handler
           (lambda ()
             (call-with-current-continuation
              (lambda (root-continuation)
            (set! editor-thread-root-continuation
                  root-continuation)
            (with-notification-output-port null-output-port
              (lambda ()
                (do ((thunks (let ((thunks editor-initial-threads))
                       (set! editor-initial-threads '())
                       thunks)
                     (cdr thunks)))
                ((null? thunks))
                  (create-thread root-continuation (car thunks)))
                (top-level-command-reader
                 edwin-initialization)))))))
         message)
           #f
           `((START-CHILD ,(editor-start-child-cmdl with-editor-ungrabbed))
         (CHILD-PORT ,(editor-child-cmdl-port (nearest-cmdl/port)))
         ,@operations))
          message))))))))

Update your Edwin init file

Then, you’ll need to tweak your Edwin init file (also known as ~/.edwin) to load this file into Edwin’s environment on startup:

(load "/path/to/open-edwin-on-file.scm" '(edwin))

Write a shell script to make it easier launch Edwin from the command line

Now that the EDIT procedure takes a filename argument, we can wrap this all up in a shell script that calls Edwin with the right arguments. There may be other ways to accomplish this than in the code shown below, but it works.

Note that the path to my local installation of MIT/GNU Scheme on Mac OS X is slightly tweaked from the official install location. What’s important is that Scheme is invoked using the right “band”, or image file. For more information, see the fine manual.

Take the code below and stick it somewhere on your $PATH; on my machine it lives at ~/bin/edwin.

#!/usr/bin/env sh

EDIT_FILE=$1
SCHEME_CODE="(edit \"$EDIT_FILE\")"

if [[ $(uname) == 'Darwin' ]]; then
  _SCHEME_DIR=/Applications/MIT-Scheme.app/Contents/Resources
  SCHEME=$_SCHEME_DIR/mit-scheme
  MITSCHEME_BAND=$SCHEME_DIR/all.com
  CMD=$SCHEME
fi

if [[ $(uname) == 'Linux' ]]; then
  CMD=scheme
fi

N=$RANDOM
F=/tmp/edit-$N.scm

touch $F
echo $SCHEME_CODE > $F

$CMD --load $F

Install an edit server

Although the extension is called ‘Edit with Emacs’, it can be used with any text editor. You just need to be able to run a local “edit server” that generates the right inputs and outputs. Since Chrome extensions can’t launch apps directly, the extension running in the browser needs to act as a client to a locally running server, which will launch the app.

Since we want to launch Edwin, we’ll need to run a local edit server. Here’s the one that I use:

https://gist.github.com/frodwith/367752

To get the server to launch Edwin, I save the gist somewhere as editserver.psgi and run the following script (for more information on the environment variables and what they mean, see the comments in the gist):

#!/usr/bin/env sh
EDITSERVER_CMD='edwin %s' \
EDITSERVER_BLOCKING=1 \
screen -d -m `which plackup` -s Starman -p 9292 -a ~/Code/mathoms/editserver.psgi

The relevant bit for running Edwin is the EDITSERVER_CMD environment variable, which we’ve set to run the edwin script shown above.

Note that this server is written in Perl and requires you to install the Starman and Plack modules. If you don’t like Perl or don’t know how to install Perl modules, there are other servers out there that should work for you, such as this one written in Python.

Edit text!

Once you’ve done everything above and gotten it working together, you should be able to click the “edit” button next to your browser textarea and start Edwin. It will look something like the following screenshot (which you saw at the beginning of this post):

edwin-editing-textarea

If you prefer video, check out this short demo on YouTube.

How to Install the Pentadactyl Firefox Add-On

wilkie-reservoir-december-2015-small

(Wilkie Reservoir, Queensbury, NY)

This post describes how to install the latest nightly build of Pentadactyl, a browser add-on for Firefox that gives it Vim-like keybindings and behavior.

These instructions are current as of the date of this post. I’m using Firefox 44.0.2 on the release channel as I write this.

On This Page

Step 1. Turn off Add-on Signing

In Firefox, open about:config. You may have to click through a nanny warning about voiding your warranty.

In the text area at the top of the config screen, type xpinstall.signatures.required. This will filter out all of the other options.

Below the text area, double-click on the xpinstall.signatures.required row, which will change the Value to false (it defaults to true).

Step 2. Download the Add-on

Go to the Pentadactyl website, click nightly builds to get the latest version (sometimes the other downloads are outdated), and download the file pentadactyl-latest.xpi.

To install the extension directly from the downloaded file:

  • Go to about:addons
  • Click the gear icon at the upper right-hand side of the screen
  • A dropdown menu will appear; select Install Add-on From File
  • A popup will appear, asking if you want to install this unverified add-on; click Install

If the extension installs, it will change the Firefox UI a lot. It will look like the GUI is gone completely, and it can be a little confusing at first. Type :help to read the built-in docs. If that doesn’t work, type :open http://5digits.org/help/pentadactyl/ to read the online version.

Troubleshooting

Pentadactyl could not be installed because it is not compatible

If the add-on installation fails because of a version mismatch, you’ll need to do the following:

Open the XPI file (which is basically just a zip file) in Vim, Emacs, or something else that can edit the contents of zip files directly. Edit the install.rdf XML file so the em:maxVersion attribute is a number equal to or higher than your Firefox version:

<em:targetApplication>
    <Description
        em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
        em:minVersion="31.0"
        em:maxVersion="42.*"/>
</em:targetApplication>

I can’t turn off extension signing

Mozilla are planning to remove the ability to turn off extension signing requirement in an upcoming version. If you are reading this after that has happened, a possible workaround is to install Firefox ESR (Extended Support Release), which is aimed at enterprise or education environments and lags several development cycles behind the “consumer” versions.

(The above photo was taken by me and is available under a Creative Commons license.)