Next: , Previous: , Up: Roam Protocol   [Contents]


13.2 Installation

To enable Org-roam’s protocol extensions, you have to add the following to your init file:

(require 'org-roam-protocol)

The instructions for setting up org-protocol are reproduced below.

We will also need to create a desktop application for emacsclient. The instructions for various platforms are shown below.

For Linux users, create a desktop application in ~/.local/share/applications/org-protocol.desktop:

[Desktop Entry]
Name=Org-Protocol
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/org-protocol

Associate org-protocol:// links with the desktop application by running in your shell:

xdg-mime default org-protocol.desktop x-scheme-handler/org-protocol

To disable the “confirm” prompt in Chrome, you can also make Chrome show a checkbox to tick, so that the Org-Protocol Client app will be used without confirmation. To do this, run in a shell:

sudo mkdir -p /etc/opt/chrome/policies/managed/
sudo tee /etc/opt/chrome/policies/managed/external_protocol_dialog.json >/dev/null <<'EOF'
{
  "ExternalProtocolDialogShowAlwaysOpenCheckbox": true
}
EOF
sudo chmod 644 /etc/opt/chrome/policies/managed/external_protocol_dialog.json

and then restart Chrome (for example, by navigating to <chrome://restart>) to make the new policy take effect.

See here for more info on the /etc/opt/chrome/policies/managed directory and here for information on the ExternalProtocolDialogShowAlwaysOpenCheckbox policy.

For MacOS, one solution is to use Platypus. Here are the instructions for setting up with Platypus and Chrome:

  1. Install and launch Platypus (with Homebrew):
brew cask install platypus
  1. Create a script launch_emacs.sh:
#!/usr/bin/env bash
/usr/local/bin/emacsclient --no-wait $1
  1. Create a Platypus app with the following settings:
| Setting                        | Value                     |
|--------------------------------+---------------------------|
| App Name                       | "OrgProtocol"             |
| Script Type                    | "env" ยท "/usr/bin/env"    |
| Script Path                    | "path/to/launch-emacs.sh" |
| Interface                      | None                      |
| Accept dropped items           | true                      |
| Remain running after execution | false                     |

Inside Settings:

| Setting                        | Value          |
|--------------------------------+----------------|
| Accept dropped files           | true           |
| Register as URI scheme handler | true           |
| Protocol                       | "org-protocol" |

To disable the “confirm” prompt in Chrome, you can also make Chrome show a checkbox to tick, so that the OrgProtocol app will be used without confirmation. To do this, run in a shell:

defaults write com.google.Chrome ExternalProtocolDialogShowAlwaysOpenCheckbox -bool true

If you’re using Emacs Mac Port, it registered its ‘Emacs.app‘ as the default handler for the URL scheme ‘org-protocol‘. To make OrgProtocol.app the default handler instead, run:

defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{"LSHandlerPreferredVersions" = { "LSHandlerRoleAll" = "-"; }; LSHandlerRoleAll = "org.yourusername.OrgProtocol"; LSHandlerURLScheme = "org-protocol";}'

Then restart your computer.

For Windows, create a temporary org-protocol.reg file:

REGEDIT4

[HKEY_CLASSES_ROOT\org-protocol]
@="URL:Org Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\org-protocol\shell]
[HKEY_CLASSES_ROOT\org-protocol\shell\open]
[HKEY_CLASSES_ROOT\org-protocol\shell\open\command]
@="\"C:\\Windows\\System32\\wsl.exe\" emacsclient \"%1\""

The above will forward the protocol to WSL. If you run Emacs natively on Windows, replace the last line with:

@="\"c:\\path\\to\\emacs\\bin\\emacsclientw.exe\"  \"%1\""

After executing the .reg file, the protocol is registered and you can delete the file.


Next: , Previous: , Up: Roam Protocol   [Contents]