My build of nnn with minor changes
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.

gutenread 1.0 KiB

1234567891011121314151617181920212223242526272829303132333435
  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. #
  9. # For example:
  10. # Wuthering Heights by Emily Brontë is at https://www.gutenberg.org/ebooks/768
  11. # So EBOOK_ID would be 768
  12. #
  13. # Shell: POSIX compliant
  14. # Author: Arun Prakash Jana
  15. EBOOK_ID=
  16. DIR=${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/"$EBOOK_ID"
  17. BROWSE_LINK="http://www.gutenberg.org/ebooks/search/?sort_order=downloads"
  18. BROWSER=w3m
  19. if [ ! -z "$EBOOK_ID" ]; then
  20. if [ ! -e $DIR ]; then
  21. mkdir -p $DIR
  22. cd $DIR
  23. curl -L -O "https://www.gutenberg.org/files/"$EBOOK_ID"/"$EBOOK_ID"-h.zip"
  24. unzip "$EBOOK_ID"-h.zip
  25. fi
  26. if [ -d $DIR ]; then
  27. "$BROWSER" $DIR/"$EBOOK_ID"-h/"$EBOOK_ID"-h.htm
  28. fi
  29. else
  30. "$BROWSER" $BROWSE_LINK
  31. fi