Subject: FVWM: Make fvwm-root read from stdin?

From: "Mark A. Nicolosi" <[email-masked]>
Date: Fri, 03 Jun 2005 07:33:49 -0500

Hi,

I'm trying to get fvwm-root to use an image piped to it. I thought if I
used /dev/stdin as the filename it would work. It doesn't. I'm using
this command:

$ convert file.jpg png:/dev/stdout | fvwm-root -r /dev/stdin

This is what I get:
[fvwm-root] failed to load image file '/proc/self/fd/0'

/dev/stdin being a symlink isn't the problem. I checked to see if
fvwm-root decides if the file is a png or xpm by extension or content.
It decides by content (ie I copied file.png to file and tried it).

Is this a bug? Is there a way around it? I guess I could use temporary
files, but that ugly...

TIA

-- 
Mark A. Nicolosi <[email-masked]>

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Michelle Konzack <[email-masked]>
Date: Fri, 3 Jun 2005 15:29:59 +0200

> Is this a bug? Is there a way around it? I guess I could use temporary

And if you use

    convert file.jpg png:/dev/stdout | fvwm-root -r -

which is the standard way to tell a program STDIN is used.

> TIA

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

---

From: Thomas Adam <[email-masked]>
Date: Fri, 3 Jun 2005 15:26:13 +0100

On Fri, Jun 03, 2005 at 07:33:49AM -0500, Mark A. Nicolosi wrote:
> Hi,
>
> I'm trying to get fvwm-root to use an image piped to it. I thought if
> I used /dev/stdin as the filename it would work. It doesn't. I'm using
> this command:

That's right, it doesn't work.

> Is this a bug? Is there a way around it? I guess I could use temporary

More a feature -- jpgs are not supported for obvious reasons.
Converting them to pngs (which is supported) would be the easiest solution.

-- Thomas Adam

--  
"One of us is a cigar stand, and one of us is a lovely blue incandescent
guillotine" -- Stephen Malkmus, "Type Slowly" from "Brighten The Corners"
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dan Espen <[email-masked]>
Date: Fri, 03 Jun 2005 10:58:47 -0400

> Is this a bug? Is there a way around it? I guess I could use temporary

I don't think it's a bug.

If you use strace to follow what goes on, Fvwm first checks
to see if the file is an XPM file.  It does that by reading
the first 4K of the file:

open("/dev/stdin", O_RDONLY)            = 4
read(4, "\211PNG\r\n\32\n\0\0\0\rIHDR\0\0\1@\0\0\0\360\10\2\0\0"..., 4096) = 4096
close(4)                                = 0

Since the file is PNG, that fails and it then tries XPM:

open("/dev/stdin", O_RDONLY)            = 4
read(4, "\350\362\201\217\24W\2425_\7 \365T\316rV\267\331\f\30\274"..., 4096) = 4096
close(4)                                = 0

That fails too, since the first 4K of stdin has already been read.
Notice how the input data is different.

The problem is that /dev/stdin is a FIFO, once you read it, you can't
close it and expect to read the same thing again.

If you use convert to change the file to an XPM, fvwm-root HAPPENS to
work, but that's just because right now it tries XPM first.

-- 
Dan Espen                           E-mail: [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Fri, 03 Jun 2005 11:00:01 -0400

Michelle Konzack <[email-masked]> writes:
> >=20
> >=20
> >=20
> >=20
> >=20

That's a convention.
A convention that fvwm-root doesn't use.

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 3 Jun 2005 15:13:33 +0000

> [fvwm-root] failed to load image file '/proc/self/fd/0'

I don't think such construction may work, programs would need to open
stdin for the second time (appending to already open stdout works well).

  % cat some.jpg | convert jpg:/dev/stdin some.png
  convert: Not a JPEG file: starts with 0x49 0x4a (/dev/stdin) [Illegal seek].

> Is this a bug? Is there a way around it? I guess I could use temporary

Yes, currently, using temp files would be reliable and portable:

  convert file.jpg /tmp/$$.png && fvwm-root -r /tmp/$$.png; rm -f /tmp/$$.png

I think you may patch fvwm-root to support "-" file argument.

Regards,
Mikhael.

---

From: Dan Espen <[email-masked]>
Date: Fri, 03 Jun 2005 12:14:09 -0400

> I think you may patch fvwm-root to support "-" file argument.

Fvwm would have to copy stdin to a file so that it could be
reread.  Unless the file was an XPM.

You can get Fvwm to try png first:

home> ln -s /dev/stdin /tmp/y.png
home> cat x.png /dev/stdout | fvwm-root -r /tmp/y.png
libpng error: Not a PNG file
Segmentation fault (core dumped)

As you can see, that doesn't help.
An strace reveals libpng trying to do an lseek
and getting Illegal Seek.