swissChili | c6b0536 | 2022-09-04 18:32:07 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | shopt -s lastpipe |
| 4 | |
| 5 | epub="$(zenity --file-selection)" |
| 6 | files="$(mktemp -d)" |
| 7 | unzip "$epub" -d "$files" |
| 8 | |
| 9 | # get list of xhtml files to display |
| 10 | xhtmls="$(ls "$files"/OEBPS/*.xhtml | xargs -l basename)" |
| 11 | |
| 12 | choosepart() { |
| 13 | echo "$xhtmls" | zenity --list --title "epub parts | $epub" \ |
| 14 | --text "Choose a part" \ |
| 15 | --column "Parts" \ |
| 16 | --width 400 --height 400 \ |
| 17 | | read part |
| 18 | |
| 19 | if [ "$part" = "" ]; then |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | echo part $part |
| 24 | |
| 25 | path="$files/OEBPS/$part" |
| 26 | cat "$path" "$(dirname $0)/script.html" > "$path.html" |
| 27 | |
| 28 | firefox "$path.html" |
| 29 | } |
| 30 | |
| 31 | while choosepart; do |
| 32 | true |
| 33 | done |
| 34 | |
| 35 | rm -rf "$files" |