It is almost two years since I have discovered an amazing org-mode. I am using it in more situations every day, so recently, I wrote a simple tray application to use org-protocol with defined org-capture templates directly from the desktop.

QT org-mode systray

Emacs configuration

Minimal Emacs configuration requires setting up org-mode, org-protocol, emacs server modes and org-capture-templates.

(add-to-list 'load-path "~/.emacs.d/org-8.3.2/lisp/")
(add-to-list 'load-path "~/.emacs.d/org-8.3.2/contrib/lisp/" t)

(require 'org)
(require 'org-protocol)

(setq org-capture-templates
  '(   
    ("b" "Capture link over org-protocol" 
         entry (file+headline "/home/milosz/Documents/bookmarks.org" "Bookmark inbox")
        "** %:description\n   [[%:link][%:link]] \n   CREATED: %U\n\n   %i"  
         :immediate-finish 1 :empty-lines 1) 
    ("t" "Capture todo over org-protocol"
         entry (file+headline "/home/milosz/Documents/agenda.org" "Future tasks")
         "** TODO %:link \n   CREATED: %U\n   SOURCE: %:description\n\n   %:initial"
         :immediate-finish 1 :empty-lines 1 :prepend t)
    ("i" "Capture an idea over org-protocol"
         entry (file+headline "/home/milosz/Documents/blog.org" "Ideas")
	 "** TODO %:link \n   CREATED: %U\n   SOURCE: %:description\n\n   %:initial"
         :immediate-finish 1 :empty-lines 1 :prepend t)
   )
)

(global-set-key "\C-cc" 'org-capture)

(server-start)
Inspect template expansion and org-protocol.el source code (especially org-protocol-do-capture function) for more information.

Shell scripts

These shell scripts are designed to verify that emacs daemon process is running and then intercept a call from emacsclient to trigger custom capture action.

Todo entry

Store the following shell script as ~/.emacs.d/org-add-todo.sh file.

#!/bin/sh
# Use org-protocol to add new todo entry
# params: title source description

(lsof -c emacs 2>/dev/null| grep -q server) || (emacs --daemon 2>/dev/null)

if [ "$#" -eq 3 ]; then
  emacsclient "org-protocol://capture://t/$1/$2/$3"
fi

You can use it to add a new todo entry using only a text terminal.

$ sh org-add-todo.sh "Create code repository" "shell" "Create and publish code repository"

Content will be stored in the /home/milosz/Documents/agenda.org file.

* Future tasks

** TODO Create code repository 
   CREATED: [2016-04-21 czw 21:19]
   SOURCE: shell

   Create and publish code repository

Idea entry

Store the following shell script as ~/.emacs.d/org-add-idea.sh file.

#!/bin/sh
# Use org-protocol to add new idea entry
# params: title source description

(lsof -c emacs 2>/dev/null | grep -q server) || (emacs --daemon 2>/dev/null)

if [ "$#" -eq 3 ]; then
  emacsclient "org-protocol://capture://i/$1/$2/$3"
fi

You can use it to add a new idea entry using only a text terminal.

$ sh org-add-idea.sh "Create org-mode blog post" "shell" "Create org-mode + org-protocol blog post"

Content will be stored in the /home/milosz/Documents/blog.org file.

* Ideas

** TODO Create org-mode blog post 
   CREATED: [2016-04-21 czw 22:00]
   SOURCE: shell

   Create org-mode + org-protocol blog post

Bookmark entry

Store the following shell script as ~/.emacs.d/org-add-bookmark.sh file.

#!/bin/sh
# Use org-protocol to add new bookmark entry
# param: url title description

(lsof -c emacs 2>/dev/null | grep -q server) || (emacs --daemon 2>/dev/null)

if [ "$#" -eq 3 ]; then
  emacsclient "org-protocol://capture://b/$(echo $1 | sed 's|/|%2F|g')/$2/$3"
fi

You can use it to add a new bookmark entry using only a text terminal.

$ sh org-add-bookmark.sh "https://sleeplessbeastie.eu/" "Personal domain" "Personal web space"

Content will be stored in the /home/milosz/Documents/bookmarks.org file.

* Bookmark inbox

** Personal domain
   [[https://sleeplessbeastie.eu/][https://sleeplessbeastie.eu/]] 
   CREATED: [2016-04-21 czw 22:11]

   Personal web space
Use sed 's|/|%2F|g' to replace / character and sed 's|n|%0A|' to replace new line character.

System tray application

The application is available (source code) inside QT org-mode tray repository.

QT org-mode dialog

I have tested everything using <a href="https://www.qt.io/" target="_blank" rel="external nofollow noopener noreferrer">Qt</a> 5.6 and Ubuntu OS.

Remember to use Emacs client which works in conjunction with the built-in Emacs server.
ko-fi