lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about autocompile bash script


From: Carl Peterson
Subject: Question about autocompile bash script
Date: Mon, 9 Sep 2013 13:08:28 -0400

Question for those who are familiar with linux bash shell scripting...

I have a script running on my linux box that uses inotifywait to monitor a folder and compile any changed lilypond files. The folder is tied to my dropbox account, so I can upload files to dropbox from any computer and have the PDF and MIDI files within a few seconds, as if I were directly on the computer (and without the need for an ssh connection). Here is the script:

inotifywait -m -e attrib,create ../output |
while read dir ev file; do
lilypond --output=../files/ "$file"
done

This was adapted from a script I found online for this purpose. I use the output parameter to send the files to another folder so that the files (particularly the .ps file, in my experience) doesn't trigger the compiler and I don't have to mess with regex filters.

The question I have is whether it is possible to set up a similar script to "trace" a file's inclusion in other lilypond files and then compile whenever an upstream file is loaded. My template/framework for hymn settings uses discrete levels of file inclusions.

* For each hymn, I have a lyrics file and a music file, which define variables for those things, as well as provide the applicable header information (composer attribution in music file, poet attribution in lyrics file, for example, stored as variables).

* The lyrics and music files are both included into a "setting" file (for the unique combination of lyrics and music). As part of this settings file, I also create variables that define the treble and bass clefs for the music output (eventually, this step will be done using a separate file as well, but for now, this works).

* The setting file is included in an "output" file, which calls the layout-specific headers and \layout block (though right now, all layouts use the same block), and calls the music and lyrics to build the actual score(s) (multiple scores if outputting to the slide/beamer layout, where each verse is its own score). This is the file that is eventually compiled.

So here's what I'm trying to figure out...

1) If I upload a new lyrics or music file to the folders bearing those names, check the settings folder for any file that includes the changed file.

2) If such a file is found (typically, there is only one, but as this project develops, there could be multiple matches), search the output folder for a file that includes the changed settings file.

3) If such a file is found (right now, there are three different layouts under consideration), compile that file.

One thought I had was cascading inotifywait triggers. The one on the output file remains, but then, add one to the settings folder that changes a trivial attribute (modified date, for instance) of any output files (which would trigger the output file script). Do the same thing for the music and lyrics folders to change the date on the settings folders. The "lyrics" "music" "settings" and "output" folders are all at the same directory level.

Any thoughts or has anyone already figured this out?

Thanks,
Carl

reply via email to

[Prev in Thread] Current Thread [Next in Thread]