So what I'm trying to do was to displaying image on remote server, and moving them- I have think a way to achieve this with wmctrl and ImageMagick's display, so I wrote a simple command.

cat "$img" | ssh "beer@laika" "export DISPLAY=:0; display - & sleep 5 && wmctrl -r ImageMagick -e 0,254,600,800,560"

Where $img is the a variable that takes png, jpeg, and jpg file as an input— the problem is above method doesn't seem to be working, the error is.

display: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.

It seems display didn't accept the input properly, I think some process had absorb the stdin.

I tried debugging the command, and found out if the command that takes place after display - get removed— it works ! the image would be displayed on my remote server.

cat "$img" | ssh "beer@laika" "export DISPLAY=:0; display -"

↑↑ Worked ↑↑

If I manually move the window through ssh, it would ran successfully without any problem.

ssh beer@laika "export DISPLAY=:0; wmctrl -r ImageMagick -e 0,254,600,750,480"

↑↑ Worked ↑↑

What could be the problem ? Anyone can shed some light for me ?

2 Answers 2


The problem is with the standard input.

A way of solving it is to transfer the file first (the cat > filename), and then run the commands, so your command line would be, for example:

cat "$img" | ssh beer@laika "export DISPLAY=:0; cat > /tmp/temporary_image;display /tmp/temporary_image &  sleep 5;wmctrl -r ImageMagick -e 0,254,600,750,480"
  • Pressing C at the display GUI window is sent as an X11 event -- it's not the same as sending it via stdin. Jan 15, 2020 at 18:49
  • @user1686 the problem is display and stdin, that's the point and the solution works. But you're right so I removed the reference to the C key in the answer. Thanks! Jan 15, 2020 at 18:57
  • Thanks for the workaround, it really useful
    – Liso
    Jan 16, 2020 at 14:20

You cannot send stdin to a background job, generally. If the process is started with & then the shell will actually redirect its stdin from /dev/null to avoid any read attempts.

(And the process it was started normally from an interactive terminal but Ctrl+Z'd and 'bg'd later, it would receive a SIGTTIN whenever it tried to read from the terminal.)

So you'll need either to first receive the image into a temporary file, or to replace the & usage with a custom tool. For example, use the 'subprocess' module in Python, or Open3() in Ruby – they give you much more control over which FDs to pass.

It might be possible to do it from within the shell itself, as explicit redirections override this:

display - < /dev/stdin &

Actually, it would be best to specify the position up front and avoid the delayed move. Most X11 programs traditionally accept the -geometry option, so check if this works:

display -geometry "WIDTHxHEIGHT+XOFFSET+YOFFSET" -
  • Thanks ! I didn't know that option exist, gonna test it tomorrow in my office.
    – Liso
    Jan 15, 2020 at 15:00
  • I started a question on AskUbuntu and raised a bounty there.
    – Liso
    Jan 22, 2020 at 2:48

You must log in to answer this question.

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