On 05/01/2024 03:46, David Wright wrote:
On Thu 04 Jan 2024 at 23:34:28 (+0100), Volodymyr Prokopyuk wrote:

I know that lilypond can receive a source.ly file from the stdin by
using lilypond
-. Is it possible for lilypond to output PDF to the stdout?

My motivation behind using lilypond in a pipeline is to speed up PDF
generation by avoiding storing intermediary files on disk. The pipeline I'd
like to implement is
cat source.ly | lintLy | lilypond - | optimizePDF > score.pdf
Currently lilypond engraves PDF on disk, so a PDF optimizer has to read,
optimize, and substitute PDF on disk.

You could create a RAM disk to hold your intermediate files,
something along the lines of:

    Ramdir="/dev/shm/${FUNCNAME[0]}$(printf '%(%s)T' -1)"
  $ mkdir -p "$Ramdir"

The first line (which I run in a bash function, for a quite different
purpose) creates a pseudounique but recognizable name, and the second
line creates the directory.

Cheers,
David.


Alternatively, use a fifo, e.g.

fifo=/var/tmp/ly-pdf$$
rm -rf $fifo
mknod  $fifo p
cat source.ly | lintLy | lilypond -o $fifo &
optimizePDF  < $fifo > score.pdf
wait
rm -rf $fifo

A trick I learned when doing Oracle backups. It also would not write to stdout.

--
Political correctness: a kind of McCarthyite movement in reverse which,
in the name of tolerance proscribes all reference to gender, ethnicity,
color of skin, sexual preference, social provenance and even age. It has
no leaders, as far as I am aware, only terrified disciples. - John le Carre

Reply via email to