summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/impressive-display38
1 files changed, 28 insertions, 10 deletions
diff --git a/bin/impressive-display b/bin/impressive-display
index 6d4244e..d47195c 100755
--- a/bin/impressive-display
+++ b/bin/impressive-display
@@ -6,6 +6,7 @@
# Copyright (C) 2012-2016 by Debian Edu project, http://wiki.debian.org/DebianEdu
# 2012-2016, Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
# 2016, Daniel Teichmann <daniel@teichm-sh.de>
+# 2022, Dominik George <dominik.george@teckids.org>
# Impressive PDF Display is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,6 +37,11 @@
VERSION="0.3.3"
+SUPPORTED_FILES=(pdf jpg jpeg png tif bmp ppm avi)
+if type -p mplayer 1>/dev/null; then
+ SUPPORTED_FILES+=(mov mp4 mkv webm ogv mpg mpeg ts flv)
+fi
+
# Can be configured at "/etc/default/impressive-display"
DEFAULT_PDF_URI="file:///usr/share/doc/impressive-display/impressive-display.pdf.gz"
DEFAULT_RESOLUTION=""
@@ -97,9 +103,9 @@ fi
workdir="$HOME/.impressive-display"
mkdir -p "$workdir"
-pdffile_previous="$workdir/impressive-pdffile-previous.pdf"
-pdffile_downloaded="$workdir/impressive-pdffile-downloaded.pdf"
-pdffile_display="$workdir/impressive-pdffile-display.pdf"
+pdffile_previous="$workdir/impressive-pdffile-previous"
+pdffile_downloaded="$workdir/impressive-pdffile-downloaded"
+pdffile_display="$workdir/impressive-pdffile-display"
session_lock="$workdir/.session-lock.$$"
impressive_lock="$workdir/.impressive-lock"
@@ -156,11 +162,23 @@ else
RESOLUTION="$DEFAULT_RESOLUTION"
fi
-if ! echo "$PDF_URI" | grep -q -E "^(file://|http://|https://).*"; then
- $OUTPUT "ERROR: PDF_URI format not supported: $PDF_URI"
- $OUTPUT " Use file://<path>/<file>.pdf(.gz) or http(s)://<host>/<path>/<file>.pdf. Doing nothing."
- exit -1
-fi
+function uri_is_supported {
+ check_uri=$1
+
+ if ! echo "$check_uri" | grep -q -E "^(file://|http://|https://).*"; then
+ $OUTPUT "ERROR: PDF_URI format not supported: $check_uri"
+ $OUTPUT " Use file://<path>/<file>(.gz) or http(s)://<host>/<path>/<file>. Doing nothing."
+ $OUTPUT " Supported file types are: ${SUPPORTED_FILES[@]}"
+ return -1
+ fi
+}
+
+uri_is_supported "$PDF_URI" || exit -1
+uri_stripped=${PDF_URI%.gz}
+extension=${uri_stripped##*.}
+pdffile_previous=$pdffile_previous.${extension}
+pdffile_downloaded=$pdffile_downloaded.${extension}
+pdffile_display=$pdffile_display.${extension}
if [ -n "${RESOLUTION}" ]; then
if type -p xrandr 1>/dev/null; then
@@ -356,13 +374,13 @@ function download_pdffile {
$OUTPUT "INFO: Triggering PDF file reload, PDF file has changed..."
fi
- pdffile=$pdffile_display
-
else
$OUTPUT "WARNING: PDF file format problems. Maybe not a PDF file?"
+ cp "$pdffile_downloaded" "$pdffile_display"
fi
+ pdffile=$pdffile_display
}