How to copy the org-protocol://roam-file... URL to any org-roam file?

If I generate a graph with org-roam-graph it includes links back to my notes in Emacs / org-roam (of the type org-protocol://roam-file? I was wondering how to create these URLs when I am in Emacs, visiting an org-roam file. This probably is trivial but I have been unable to figure it out so far.

Just curious, what’s your use case for using org-protocol to go from org-mode file in Emacs to another org-mode file in Emacs?

Oh, it is not for use within Emacs. These links allow to refer to org-roam files from other applications on macOS, for example Todoist, Zotero or even a Google Doc.

This is the solution. Just in case anyone has the same needs :slight_smile:

I use these links in Zotero and Todoist.

(defun my-copy-orgroam-URL-to-clipboard ()
  "Create a URL for the current orgroam file and copy it to the clipboard"
  (let ((filename (if (equal major-mode 'dired-mode)
    (when filename
       (insert (concat "org-protocol://roam-file?file=" filename))
        (clipboard-kill-region (point-min) (point-max)))
      (message "URL copied to clipboard"))))