1
Enhancement Requests / Re: Command line option to set the effective date
« on: November 28, 2017, 06:58:37 PM »
I decided to use a different technique so I'll share my code here
This replaces the text %DAY_COUNT% with the countdown, whoever uses it needs to edit the variables at the begining.
This replaces the text %DAY_COUNT% with the countdown, whoever uses it needs to edit the variables at the begining.
Code: [Select]
#!/bin/sh
SUB_TEXT="%DAY_COUNT%"
ORIG_FILE="days_countdown.xml"
DST_DIR="countdown_fseqs_new"
XLIGHTS_BIN="/Applications/xLights.app/Contents/MacOS/xLights"
XLIGHTS_DIR="/Users/USER_DIR/Dropbox/Xlights"
XLIGHTS_OPTS="-m $XLIGHTS_DIR -s $XLIGHTS_DIR -r"
if [ ! -d "$DST_DIR" ]; then
echo Destination dir $DST_DIR does not exists
exit
fi
echo "=========================================" >> $DST_DIR/xlights.log
echo "*** Starting render $(date) ***" >> $DST_DIR/xlights.log
echo "=========================================" >> $DST_DIR/xlights.log
for i in $(seq $1); do
i_PADDED=$(printf %02d $i)
if [[ $i == 1 ]]; then
TEXT="1 day"
else
TEXT="$i days"
fi
echo "Substituting for $TEXT" >> $DST_DIR/xlights.log
echo "=========================================" >> $DST_DIR/xlights.log
sed "s/$SUB_TEXT/$TEXT/" < $ORIG_FILE > tmp.xml
$XLIGHTS_BIN $XLIGHTS_OPTS tmp.xml >> $DST_DIR/xlights.log
if [[ $? != 0 ]]; then
echo Error rendering
exit
fi
mv tmp.fseq $DST_DIR/days$i_PADDED.fseq
echo "=========================================" >> $DST_DIR/xlights.log
done
rm tmp.xml