summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/impressive-display34
1 files changed, 21 insertions, 13 deletions
diff --git a/bin/impressive-display b/bin/impressive-display
index cf255e1..cc7b07c 100755
--- a/bin/impressive-display
+++ b/bin/impressive-display
@@ -78,6 +78,8 @@ DOWNLOAD_INTERVAL="600"
RUSH_HOURS="07-11"
RUSH_HOURS_DOWNLOAD_INTERVAL="180"
+LOG_TO_SYSLOG=
+
# Disable PDF downloads at night time completely...
SLEEP_HOURS="22-06"
SLEEP_HOURS_DOWNLOAD_INTERVAL="0"
@@ -103,6 +105,12 @@ if [ -r $HOME/.impressive-display-rc ] && [ ! -d $HOME/.impressive-display-rc ];
. $HOME/.impressive-display
fi
+if [ -z "$LOG_TO_SYSLOG" ]; then
+ OUTPUT="echo"
+else
+ OUTPUT="logger -t impressive-display"
+fi
+
workdir="$HOME/.impressive-display"
mkdir -p "$workdir"
pdffile_previous="$workdir/impressive-pdffile-previous.pdf"
@@ -202,7 +210,7 @@ function cleanup {
function pdf_is_portrait {
if ! which bc 1>/dev/null; then
- echo "WARNING: The 'bc' command line tool is not installed on this system."
+ $OUTPUT "WARNING: The 'bc' command line tool is not installed on this system."
return -1
fi
@@ -239,7 +247,7 @@ function merge_portrait_documents {
cp "$pdffile_downloaded" "$pdffile_display"
fi
else
- echo "WARNING: The pdfnup tool is not installed."
+ $OUTPUT "WARNING: The pdfnup tool is not installed."
cp "$pdffile_downloaded" "$pdffile_display"
fi
@@ -341,7 +349,7 @@ function download_pdffile {
else
- echo "WARNING: PDF file format problems. Maybe not a PDF file?"
+ $OUTPUT "WARNING: PDF file format problems. Maybe not a PDF file?"
fi
@@ -358,30 +366,30 @@ function download_loop {
while [ -e "$session_lock" ]; do
if [ -n "$DEBUG_DOWNLOADS" ]; then
- echo "DEBUG: rush hour: `is_rush_hour` (interval: $RUSH_HOURS_DOWNLOAD_INTERVAL), sleep hour: `is_sleep_hour` (interval: $SLEEP_HOURS_DOWNLOAD_INTERVAL). Normal interval: $DOWNLOAD_INTERVAL."
+ $OUTPUT "DEBUG: rush hour: `is_rush_hour` (interval: $RUSH_HOURS_DOWNLOAD_INTERVAL), sleep hour: `is_sleep_hour` (interval: $SLEEP_HOURS_DOWNLOAD_INTERVAL). Normal interval: $DOWNLOAD_INTERVAL."
fi
if is_rush_hour 1>/dev/null && [ "x$RUSH_HOURS_DOWNLOAD_INTERVAL" != "x0" ]; then
sleep $RUSH_HOURS_DOWNLOAD_INTERVAL
if [ -n "$DEBUG_DOWNLOADS" ]; then
- echo "RUSH HOUR download, URL: $PDF_URL"
+ $OUTPUT "INFO: RUSH HOUR download, URL: $PDF_URL"
fi
download_pdffile
elif is_sleep_hour 1>/dev/null && [ "x$SLEEP_HOURS_DOWNLOAD_INTERVAL" != "x0" ]; then
sleep $SLEEP_HOURS_DOWNLOAD_INTERVAL
if [ -n "$DEBUG_DOWNLOADS" ]; then
- echo "SLEEP HOUR download, URL: $PDF_URL"
+ $OUTPUT "INFO: SLEEP HOUR download, URL: $PDF_URL"
fi
download_pdffile
elif (! is_rush_hour 1>/dev/null ) && (! is_sleep_hour 1>/dev/null) && [ "x$DOWNLOAD_INTERVAL" != "x0" ]; then
sleep $DOWNLOAD_INTERVAL
if [ -n "$DEBUG_DOWNLOADS" ]; then
- echo "NORMAL HOUR download, URL: $PDF_URL"
+ $OUTPUT "INFO: NORMAL HOUR download, URL: $PDF_URL"
fi
download_pdffile
else
if [ -n "$DEBUG_DOWNLOADS" ]; then
- echo "DEBUG: Not doing any download."
+ $OUTPUT "DEBUG: Not doing any download."
fi
sleep 60
fi
@@ -416,7 +424,7 @@ function reloadable_impressive {
done
else
- echo "ERROR: The impressive application is not installed."
+ $OUTPUT "ERROR: The impressive application is not installed."
fi
}
@@ -432,23 +440,23 @@ function create_lock {
### MAIN ###
-echo "INFO: $(basename $0) version $VERSION"
+$OUTPUT "INFO: $(basename $0) version $VERSION"
if [ -n "$PDF_URL" ]; then
- echo "INFO: PDF_URL is configured. Using PDF file from given URL: $PDF_URL"
+ $OUTPUT "INFO: PDF_URL is configured. Using PDF file from given URL: $PDF_URL"
create_lock
download_loop
elif [ -n "$PDF_FILE" ]; then
- echo "INFO: PDF_FILE is configured. Using local PDF file: $PDF_FILE"
+ $OUTPUT "INFO: PDF_FILE is configured. Using local PDF file: $PDF_FILE"
create_lock
local_pdffile
else
- echo "ERROR: Neither PDF_FILE nor PDF_URL has been configured. Doing nothing."
+ $OUTPUT "ERROR: Neither PDF_FILE nor PDF_URL has been configured. Doing nothing."
exit 0
fi