Sean Meighan

Software => Enhancement Requests => Topic started by: bshep on November 28, 2017, 02:35:34 PM

Title: Command line option to set the effective date
Post by: bshep on November 28, 2017, 02:35:34 PM
Would it be possible to add a command line option to set the effective date ( alternatively to set a variable used when rendering)

This would be useful when making countdown sequences without the need for xSchedule.  Right now generating the countdown is a manual process of changing the text on the UI and rendering, saving the file somewhere else and repeating.

Thanks!

Bruce
Title: Re: Command line option to set the effective date
Post by: keithsw1111 on November 28, 2017, 03:10:17 PM
You could just set your pc time.
Title: Re: Command line option to set the effective date
Post by: bshep on November 28, 2017, 03:25:17 PM
That works! Thanks for the suggestion
Title: Re: Command line option to set the effective date
Post by: bshep 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.

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