Org-roam UI

about | blog | config | notes | github

1. Frontend for Org-roam

org-roam-ui is meant as the successor for Org-roam-server

2. Configuration

2.1. Setup Dependencies

We need to make sure Org-roam is setup first.

(require 'init-org-roam)

2.2. Package Install

(use-package org-roam-ui
  :straight (:host github :repo "org-roam/org-roam-ui" :branch "main" :files ("*.el" "out"))
  :after org-roam)

2.3. Customize Parameters

(setq org-roam-ui-sync-theme t)
(setq org-roam-ui-follow t)
(setq org-roam-ui-update-on-save t)
(setq org-roam-ui-open-on-start nil)

2.4. Initialize Server

Run the server if we are running in daemon mode.

(when (daemonp)
  (add-hook 'after-init-hook #'org-roam-ui-mode))

2.5. Feature Provide

(provide 'init-org-roam-ui)

3. Integration with Surf

In order to keep my browser session seperate from the org-roam-ui webapp, I use the Surf Browser. Let's ensure that it gets started at login by creating a xinit user level scripts. Here we control the position and size of the browser with herbstluftwm.

# start a subshell so we don't block other things from loading
(
    # delay by 2 seconds so emacs daemon has time to load
    sleep 2
    if [ -n "$(pgrep -f 'emacs --daemon=xorg-emacs-daemon')" ] && \
       [ -f "~/.config/enable_surf" ] && \
       [ -z "$(pgrep -f 'surf http://127.0.0.1:35901/')" ]; then

        fix_surf_window() {
            herbstclient lower "$1"
            xdotool windowmove "$1" 0 20
            width=$(xwininfo -root|grep -E '  Width:'|cut -d ':' -f2)
            height=$(($(xwininfo -root|grep -E '  Height:'|cut -d ':' -f2) - 40))
            xdotool windowsize "$1" ${width} ${height}
        }

        # fork this too so we don't block things
        fix_surf_window $(herbstclient --last-arg --wait rule surfdesktop) &
        surf "http://127.0.0.1:35901/" &
    fi

) &

Created: 2021-11-13

Emacs 26.1 (Org mode 9.5)