LyX auto generate pdf

19-Apr-2013 | scripts

This script permit to automatically generate the PDF output when you are working on LyX files. You need to install the "inotify-tools" package:

$ sudo aptitude install inotify-tools
#!/bin/bash --posix

set -u

error()
{
    echo >&2 $*
    exit 1
}

typeset -r CMD_WHICH="/usr/bin/which"
typeset -r CMD_LYX=$($CMD_WHICH lyx)
[[ -x $CMD_LYX ]] || error "lyx command not found !"

typeset -r CMD_INOTIFYWAIT=$($CMD_WHICH inotifywait)
[[ -x $CMD_INOTIFYWAIT ]] || error "inotifywait command not found !"

while true
do
    $CMD_INOTIFYWAIT *.lyx
    $CMD_LYX -batch -e pdf2 -f 01_master.lyx
    (( $? == 0 )) || error "error generating pdf!"
done

exit 0

# EOF