You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pubreader 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env bash
  2. read_epub()
  3. {
  4. einfo -q -p $1 | elinks -force-html -dump
  5. }
  6. read_html()
  7. {
  8. elinks -dump $1
  9. }
  10. read_txt()
  11. {
  12. cat $1
  13. }
  14. view_txt()
  15. {
  16. book="$(dialog --backtitle "Choose a text file" --fselect $HOME 0 0 --stdout)"
  17. dialog --backtitle "$book" --textbox $book 0 0
  18. }
  19. view_html()
  20. {
  21. book="$(dialog --backtitle "Choose an HTML file" --fselect $HOME 0 0 --stdout)"
  22. read_html $book > $HOME/.etemp.txt
  23. dialog --backtitle "$1" --textbox $HOME/.etemp.txt 0 0
  24. rm $HOME/.etemp.txt
  25. }
  26. show_metadata()
  27. {
  28. einfo $1
  29. }
  30. view_epub()
  31. {
  32. book="$(dialog --backtitle "Choose a book" --fselect $HOME/Books/ 0 0 --stdout)"
  33. read_epub $book > $HOME/.etemp.txt
  34. dialog --backtitle "$book" --textbox $HOME/.etemp.txt 0 0
  35. rm $HOME/.etemp.txt
  36. }
  37. do_help()
  38. {
  39. cat << EOF
  40. Usage:
  41. $0 -r {epub,html,txt} file | less
  42. Dump a file according to specified format to standard output for pagers like less.
  43. $0 -m file
  44. Show an ePub book's metadata.
  45. $0 -v {epub,html,txt}
  46. Select and read a file via curses dialogs.
  47. $0 -h
  48. Display this help page.
  49. EOF
  50. }
  51. if [ -e ~/.pubreader.rc ];then
  52. source ~/.pubreader.rc
  53. else
  54. cat > ~/.pubreader.rc << EOF
  55. #add new functions below
  56. EOF
  57. source ~/.pubreader.rc
  58. fi
  59. while getopts "r:m:v:h" option;do
  60. case "$option" in
  61. r) read_${OPTARG} $3;;
  62. m) show_metadata ${OPTARG};;
  63. v) view_${OPTARG};;
  64. h) do_help;;
  65. esac
  66. done