#!/bin/bash ### A helper script for reading ebooks ### # Copyright 2009 Ertug Karamatli # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ### USAGE ### # 1. Set EBOOK_ARCHIVE setting to where your PDFs are. # 2. Create a pageinfo dir somewhere and set EBOOK_PAGEINFO setting to # that dir. # 3. Run this script. ### SETTINGS ### EBOOK_ARCHIVE="/home/ertug/ebook/arsiv" EBOOK_PAGEINFO="/home/ertug/ebook/pageinfo/" ### TODO ### # - Show last page numbers on the menu cd $EBOOK_ARCHIVE OLD_IFS=$IFS IFS=' ' pdfs=( $(find | grep '.pdf$') ) IFS=$OLD_IFS unset m; i=0 for w in "${pdfs[@]}"; do m[i++]=$(ls -i "$w" | awk '{ print $1 }') m[i++]=$w done dialog --menu "Select a book" 0 0 0 "${m[@]}" 2> /tmp/readbook.dialog INODE=$(cat /tmp/readbook.dialog) FILE=$(find -inum $INODE | cut -b 3-) cd $EBOOK_PAGEINFO prevlp=$(cat "${FILE//\//-}.page") xrandr -o left cd $EBOOK_ARCHIVE xpdf -rv -fullscreen "$FILE" $prevlp xrandr -o normal echo "Enter last page (default: $prevlp):" read lp if [ -z "$lp" ]; then lp=$prevlp fi cd $EBOOK_PAGEINFO echo $lp > "${FILE//\//-}.page"