My build of nnn with minor changes
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

50 рядки
1.6 KiB

  1. #!/usr/bin/env sh
  2. # Description: Browse Project Gutenberg catalogue by popularity, then download
  3. # and read a book of your choice.
  4. #
  5. # Details: Set the variable EBOOK_ID to download in html format and read in w3m.
  6. # Clear EBOOK_ID to browse available ebooks by popularity and set it to
  7. # the ID once you find an interesting one.
  8. # To dowload and read in epub format set READER to an epub reader like
  9. # epr: https://github.com/wustho/epr
  10. #
  11. # More on EBOOK_ID:
  12. # Wuthering Heights by Emily Brontë is at https://www.gutenberg.org/ebooks/768
  13. # So EBOOK_ID would be 768
  14. #
  15. # Downloaded ebooks are at ${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/
  16. #
  17. # Shell: POSIX compliant
  18. # Author: Arun Prakash Jana
  19. EBOOK_ID="${EBOOK_ID}"
  20. DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/$EBOOK_ID"
  21. BROWSE_LINK="http://www.gutenberg.org/ebooks/search/?sort_order=downloads"
  22. BROWSER="${BROWSER:-w3m}"
  23. READER="${READER}"
  24. if [ -n "$EBOOK_ID" ]; then
  25. if [ ! -e "$DIR" ]; then
  26. mkdir -p "$DIR"
  27. cd "$DIR" || exit 1
  28. if [ -z "$READER" ]; then
  29. curl -L -O "https://www.gutenberg.org/files/$EBOOK_ID/$EBOOK_ID-h.zip"
  30. unzip "$EBOOK_ID"-h.zip
  31. else
  32. curl -L -o "$EBOOK_ID".epub "http://www.gutenberg.org/ebooks/$EBOOK_ID.epub.noimages"
  33. fi
  34. fi
  35. if [ -d "$DIR" ]; then
  36. if [ -z "$READER" ]; then
  37. "$BROWSER" "$DIR/$EBOOK_ID-h/$EBOOK_ID-h.htm"
  38. else
  39. "$READER" "$DIR/$EBOOK_ID.epub"
  40. fi
  41. fi
  42. else
  43. "$BROWSER" "$BROWSE_LINK"
  44. fi