5

imagemagick's import shell command takes snapshots of ones desktop. Executing

import /tmp/foo.png

will convert my cursor into a crosshair and will allow me to select a screen area to capture. However, if I attempt to bind that very command to an i3wm-hotkey it does not work.

The following keybind in my i3wm config file

# ...
bindsym $mod+m exec "import /tmp/foo.png"
# ...

produces the following error (which I can pipe out to a terminal):

import-im6.q16: unable to grab mouse `': No such file or directory @ error/xwindow.c/XSelectWindow/9187.

Why is that and how can I make it work?

Jersey
  • 203
  • 1
  • 7

1 Answers1

6

The problem is that the keybinding will fire as soon as you press Ctrl+m. Add --release to the bindsym call to make it fire when you release the key and it will work:

bindsym --release $mod+m exec "import /tmp/foo.png"

This has even been documented:

Some tools (such as import or xdotool) might be unable to run upon a KeyPress event, because the keyboard/pointer is still grabbed. For these situations, the --release flag can be used, which will execute the command after the keys have been released.

dirdi
  • 3,317