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?

1 Answer 1

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.

1
  • That is terrific. Thank you very much. I went right by that section of the documentation multiple times.
    – Jersey
    Nov 20, 2019 at 12:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .