The package org-download can help emacs integrate with ImageMagick and xclip to paste images into org files.

chage

Install ImageMagick on Arch Linux

1
❯ sudo pacman -S imagemagick

Install xclip on Arch Linux

1
❯ sudo pacman -S xclip

Save screenshot to clipboard

1
❯ import png:- | xclip -selection c -t image/png

Add the code below in i3wm config file ~/.config/i3/config to bind the command above to the shortcut $mod+Shift+s

1
bindsym --release $mod+Shift+s exec import png:- | xclip -selection c -t image/png

Setup package org-download

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(if (eq system-type 'gnu/linux)
(setq zjh-system-screenshot-method "import %s"))
(if (eq system-type 'darwin)
(setq zjh-system-screenshot-method "pngpaste %s"))
(if (eq system-type 'windows-nt)
(setq zjh-system-screenshot-method "convert clipboard: %s"))

(use-package org-download
  :after org
  :defer nil
  :custom
  (org-download-method 'directory)
  (org-download-image-dir "images")
  (org-download-heading-lvl nil)
  (org-download-timestamp "%Y%m%d-%H%M%S_")
  ;;(org-image-actual-width 300)
  (org-download-screenshot-method zjh-system-screenshot-method)
  :bind
  ("C-c o s" . org-download-screenshot)
  ("C-c o c" . org-download-clipboard)
  ("C-c o y" . org-download-yank)
  :config
  (require 'org-download))

Use cases

Paste a screenshot from clipboard

  1. Take a screenshot of a screen region and save it to Clipboard by pressing "$mod+Shift+s"

  2. Paste the screenshot from the clipboard to org file on emacs by pressing C-c o c

images/20220218-191233_screenshot.png

Copy and paste an image

  1. Right click an image and select the option "Copy Image"

  2. Paste the image from the clipboard to org file on emacs by pressing C-c o c