Created
December 29, 2017 21:42
-
-
Save tigran123/7dde846349655762a0585039318295f4 to your computer and use it in GitHub Desktop.
View DjVu files on Linux framebuffer console using fbi and ddjvu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# fbdjview --- View DjVu files on Linux framebuffer console | |
# By Tigran Aivazian, v1.0, 29 December 2017 | |
# License: GPLv3 | |
# | |
# Pre-requisites: fbi and ddjvu (Run "sudo apt install fbi djvulibre-bin" to install on Ubuntu) | |
# | |
if [ $# -ne 1 ] ; then | |
echo "Usage: fbdjview file.djvu" | |
exit 1 | |
fi | |
if [ ! -f "$1" ] ; then | |
echo "fbdjview: No such file \"$1\"" | |
exit 2 | |
fi | |
md5=$(md5sum "$1" | cut -d' ' -f1) | |
cachedir=~/.cache/fbdjview/$md5 | |
function cleanup() { | |
echo "Cleaning up $cachedir" | |
rm -rf $cachedir | |
exit | |
} | |
trap cleanup SIGINT | |
if [ ! -d $cachedir ] ; then | |
mkdir -p $cachedir | |
echo -n "Please wait, generating cache in $cachedir ..." | |
ddjvu -eachpage -scale=150 -format=tiff "$1" $cachedir/page%04d.tif || cleanup | |
fi | |
fbi -a $cachedir/page*.tif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment