Monday, May 2, 2011

Automatic Screenshot insertion in Org Mode

Trawling the org-mode mailing list , found another interesting hack on getting screenshots into your org notes.  The thread on what was originally asked is here, where the OP wanted to go from the clipboard into a named file.  One of the org members posted this reply along with the link to the elisp code.

Works on Unix-like systems with Imagemagick installed.

3 comments:

Carlo Bertini said...

original idea from Russell Adams (http://permalink.gmane.org/gmane.emacs.orgmode/40271)

use scrot

(defun org-screenshot ()
"Take a screenshot into a time stamped unique-named file in the same directory as the org-buffer and insert a link to this file."
(interactive)
(setq filename
(concat
(make-temp-name
(concat (buffer-file-name)
"_"
(format-time-string "%Y%m%d_%H%M%S_")) ) ".png"))
(call-process "scrot" nil nil nil "-s" filename)
(insert (concat "[[" filename "]]"))
(org-display-inline-images))

Rajarshi Tiwari said...

Nice idea! Thanks for posting :-)

- Rajarshi

Jagadeesh N. Malakannavar said...

nice idea. thanks much for sharing