diff options
author | Dominik George <nik@velocitux.com> | 2022-06-23 14:36:33 +0200 |
---|---|---|
committer | Dominik George <nik@velocitux.com> | 2022-06-23 14:36:33 +0200 |
commit | 24a295c05d4bf38d8319ce1aa5a66fca261a54e0 (patch) | |
tree | 316cb14a1bfac444364fb22ff2bf39156f32fa31 | |
parent | 5ce494c0febebca1df7a016681a60ea39a2ccedc (diff) | |
download | impressive-display-24a295c05d4bf38d8319ce1aa5a66fca261a54e0.tar.gz impressive-display-24a295c05d4bf38d8319ce1aa5a66fca261a54e0.tar.bz2 impressive-display-24a295c05d4bf38d8319ce1aa5a66fca261a54e0.zip |
Support other file types than PDFs
Arguably, they should have been supported before, given that the
message after failure to analyze the file as a PDF outputs a WARNING,
so this is also a bugfix fixing that case. Previously, passing an
image file was perfectly ok, but it was then silently renamed to .pdf
and passed to a very confused impressive.
-rwxr-xr-x | bin/impressive-display | 38 |
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 } |