ohmyhub / spookfox

Make Emacs speak with Firefox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spookfox

Communicate between Firefox and Emacs. Because Nyxt is just not there yet.

Caution: Spookfox is in early development and I am making breaking changes all over the place.

Windows is not supported right now. At this stage I can only test spookfox on Linux, but it should theoretically work with Mac as well.

Installation

Since I haven’t figured out convenient packaging yet, please do the following manual steps to set things up. I am going to assume you are on a Linux machine, and have cloned this repo.

Setup

Without Nix

If you don’t have Nix installed, you will need to make sure that following software are available in your $PATH.

  1. Cargo, for building spookfox Native
  2. Node.js, for building the spookfox add-on

With Nix

If you have Nix installed, you can just do nix-shell to drop into an already setup development environment. Or if you are using direnv, just do a direnv allow to achieve the same.

Install spookfox-native

  1. cd spookfox-native
  2. cargo build
  3. Edit spookfox-native/spookfox.json and change path property in it to ensure it points to your home directory.
  4. ln -s <path-to-spookfox>/spookfox-native/spookfox.json ~/.mozilla/native-messaging-hosts/

Make sure to replace <path-to-spookfox> in #3 above with where you’ve cloned the repo.

Install the addon

  1. cd spookfox-addon
  2. yarn
  3. yarn build
  4. Install in Firefox
    1. Open Firefox
    2. Go to about:addons
    3. Click on the gear icon and select ”Debug Add-Ons
    4. Click on ”Load Temporary Add-on” button
    5. Navigate to the spookfox-addon/dist directory, and click Open

Install spookfox.el

Using straight.el

Since spookfox is in early development, it is not release on Melpa yet. You can use straight.el to install it directly from where you’ve clone this repo.

(use-package spookfox
  :straight (spookfox :type git
                      :local-repo "~/Documents/work/spookfox"
                      :file "spookfox.el")
  :config
  (setq spookfox-saved-tabs-target `(file+headline ,(expand-file-name "spookfox.org" org-directory) "Tabs")))

This is how I install it in my config.

Using load-file

You can also simply use

(load-file "<path-to-spookfox>/spookfox.el")
(require 'spookfox)

Features

  1. Save all open tabs as org-mode subtrees.

    I have a habit of opening too many browser tabs open, many of which I don’t even visit as often. Although the browser would discard the tab to save resources, it is still clutter. And too easy to accidentally click on it and waste precious CPU/RAM.

    To remedy that, we can save all the browser tabs open in the browser right now in an org file. Configure the target:

    (setq spookfox-saved-tabs-target '(file+headline "~/org/browser.org" "Open Tabs"))
        

    Now you can save all your currently open browser tabs in the configured target.

    (spookfox-save-all-tabs)
        

    This will open an org capture buffer where you can preview and change the tabs as org nodes before saving.

    Note: This will not close open tabs in browser. You can have that pleasure yourself.

    Organize tabs into groups

    It is possible to create “tab groups” using org-mode tags. Applying a tag on a tab node will make it a member of that tab group. Since the org subtree of tabs can be organized in any hierarchy, you can use this to apply a tag on multiple tabs.

  2. Open a saved tab

    Once you have saved the gazillion tabs you had open in your browser, you can structure them in the spookfox-saved-tabs-target any way you desire, as long as the you maintain the integrity of properties spookfox added to :PROPERTIES: drawer.

    You can use spookfox-open-tab to select one of the saved tabs and open it in the browser connected via spookfox. It uses Emacs’ built-in completion, so if you are using something like ivy or helm you might see a completion UI.

    (spookfox-open-tab)
        

    Behavior:

    • If an existing tab is selected
      • If it is already present in browser, it is focused. Else a new tab is opened
    • If you enter a string which don’t match any existing saved tabs
      • If entered string is a valid http(s) URL, a new tab with this URL is opened. Else a search with your configured search engine is performed in the new tab.
  3. Open a tab group

    You can open a group of tabs using spookfox-open-tab-group. It will open all the tabs that belong to the group in current browser. If a tab is already open, it is not reopened but will be awoken if it is in discarded state (browsers do that to save resources).

    (spookfox-open-tab-group)
        
  4. Get active tab
    (sf--get-active-tab)
        

    I use this to quickly capture notes for what I am reading in Firefox. This is not an interactive command (i.e you can’t call it with M-x), because what would you want to do that for?

About

Make Emacs speak with Firefox


Languages

Language:Emacs Lisp 42.8%Language:TypeScript 38.4%Language:Rust 13.3%Language:JavaScript 2.8%Language:Nix 2.6%Language:Shell 0.2%