summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielsLPecke <daniel.letsplay007@gmail.com>2016-11-11 13:34:43 +0100
committerDanielsLPecke <daniel.letsplay007@gmail.com>2016-11-11 13:34:43 +0100
commit09243a40034394cab05a587b666ea7276605506b (patch)
treeac30c9d4d30c38370bfe34fcbf1fa48dd66b4479
parent8f9a900b7a7218919dda6e30f98b8513815d2ab6 (diff)
downloadimpressive-display-09243a40034394cab05a587b666ea7276605506b.tar.gz
impressive-display-09243a40034394cab05a587b666ea7276605506b.tar.bz2
impressive-display-09243a40034394cab05a587b666ea7276605506b.zip
Add var-setters + change 'PDF_URL' to 'PDF_URI'
-rwxr-xr-xbin/impressive-display52
1 files changed, 28 insertions, 24 deletions
diff --git a/bin/impressive-display b/bin/impressive-display
index b688239..033920a 100755
--- a/bin/impressive-display
+++ b/bin/impressive-display
@@ -38,10 +38,11 @@ VERSION="0.3.0"
# Can be configured at "/etc/default/impressive-display"
DEFAULT_PDF_URI="http://www.cbu.edu.zm/downloads/pdf-sample.pdf"
DEFAULT_RESOLUTION="1920x1080"
-
# Loggin credentials for websites..
-PDF_URI_CREDS=""
-PDF_URL_CREDS=""
+DEFAULT_PDF_URL_CREDS=""
+
+# all displays that need to be changed
+declare -A DISPLAYS
# launch pulseaudio daemon if not already running
WITH_PULSEAUDIO="yes"
@@ -131,26 +132,29 @@ if [ "x$HIDE_IDLE_POINTER" = "xyes" ]; then
fi
fi
-PDF_URL="$PDF_URL_SECONDARIES"
-PDF_URL_CREDS="$PDF_URL_SECONDARIES_CREDS"
-PDF_FILE="$PDF_FILE_SECONDARIES"
-RESOLUTION="$SECONDARIES_RESOLUTION"
-
# if FAKE_HOSTNAME is not empty, use that string for hostname
THIS_HOSTNAME=$(hostname -f)
if [ -n "$FAKE_HOSTNAME" ]; then
THIS_HOSTNAME="$FAKE_HOSTNAME"
fi
-for primary_display in $PRIMARY_DISPLAYS; do
- if [ "x$THIS_HOSTNAME" = "x$primary_display" ]; then
- PDF_URL="$PDF_URL_PRIMARIES"
- PDF_URL_CREDS="$PDF_URL_PRIMARIES_CREDS"
- PDF_FILE="$PDF_FILE_PRIMARIES"
- RESOLUTION="$PRIMARIES_RESOLUTION"
- break
- fi
-done
+if echo ${DISPLAYS[$THIS_HOSTNAME]} | grep "pdf_uri="; then
+ PDF_URI=`echo ${DISPLAYS[$THIS_HOSTNAME]} | sed -r -e 's/.*pdf_uri=([^|]*).*/\1/'`
+else
+ PDF_URI="$DEFAULT_PDF_URI"
+fi
+
+if echo ${DISPLAYS[$THIS_HOSTNAME]} | grep "res="; then
+ RESOLUTION=`echo ${DISPLAYS[$THIS_HOSTNAME]} | sed -r -e 's/.*res=([^|]*).*/\1/'`
+else
+ RESOLUTION="$DEFAULT_RESOLUTION"
+fi
+
+if echo ${DISPLAYS[$THIS_HOSTNAME]} | grep "creds="; then
+ PDF_URL_CREDS=`echo ${DISPLAYS[$THIS_HOSTNAME]} | sed -r -e 's/.*creds=([^|]*).*/\1/'`
+else
+ PDF_URL_CREDS="$DEFAULT_PDF_URL_CREDS"
+fi
if [ -n "${RESOLUTION}" ]; then
if which xrandr 1>/dev/null; then
@@ -325,7 +329,7 @@ function download_pdffile {
if [ -n "$PDF_URL_CREDS" ]; then
creds="-u $PDF_URL_CREDS"
fi
- curl $creds "$PDF_URL" 1> "$pdffile_downloaded" 2>/dev/null
+ curl $creds "$PDF_URI" 1> "$pdffile_downloaded" 2>/dev/null
if pdfinfo "$pdffile_downloaded" 1>/dev/null 2>/dev/null; then
@@ -364,19 +368,19 @@ function download_loop {
if is_rush_hour 1>/dev/null && [ "x$RUSH_HOURS_DOWNLOAD_INTERVAL" != "x0" ]; then
sleep $RUSH_HOURS_DOWNLOAD_INTERVAL
if [ -n "$DEBUG_DOWNLOADS" ]; then
- $OUTPUT "INFO: RUSH HOUR download, URL: $PDF_URL"
+ $OUTPUT "INFO: RUSH HOUR download, URL: $PDF_URI"
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
- $OUTPUT "INFO: SLEEP HOUR download, URL: $PDF_URL"
+ $OUTPUT "INFO: SLEEP HOUR download, URL: $PDF_URI"
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
- $OUTPUT "INFO: NORMAL HOUR download, URL: $PDF_URL"
+ $OUTPUT "INFO: NORMAL HOUR download, URL: $PDF_URI"
fi
download_pdffile
else
@@ -437,9 +441,9 @@ function create_lock {
$OUTPUT "INFO: IMPRESSIVE Display (version $VERSION)"
$OUTPUT "INFO: HOSTNAME set to: $THIS_HOSTNAME"
-if [ -n "$PDF_URL" ]; then
+if [ -n "$PDF_URI" ]; then
- $OUTPUT "INFO: PDF_URL is configured. Using PDF file from given URL: $PDF_URL"
+ $OUTPUT "INFO: PDF_URI is configured. Using PDF file from given URL: $PDF_URI"
create_lock
download_loop
@@ -451,7 +455,7 @@ elif [ -n "$PDF_FILE" ]; then
else
- $OUTPUT "ERROR: Neither PDF_FILE nor PDF_URL has been configured. Doing nothing."
+ $OUTPUT "ERROR: Neither PDF_FILE nor PDF_URI has been configured. Doing nothing."
exit 0
fi