| Title: Autoscrolling text for lazy reading | |
| Author: Solène | |
| Date: 17 May 2018 | |
| Tags: unix | |
| Description: | |
| Today I found a software named | |
| [Lazyread](http://lazyread.sourceforge.net/) which can read and | |
| display file an autoscroll at a chosen speed. I had to read its source | |
| code to make it work, the documentation isn't very helpful, it doesn't | |
| read ebooks (as in epub or mobi format) and doesn't support | |
| stdin... This software requires some C code + a shell wrapper to | |
| works, it's complicated for _only_ scrolling. | |
| So, after thinking a few minutes, the autoscroll can be reproduced | |
| easily with a very simple awk command. Of course, it will not have the | |
| interactive keys like lazyread to increase/decrease speed or some | |
| others options, but the most important part is there: | |
| **autoscrolling**. | |
| If you want to read a file with a rate of 1 line per 700 millisecond, | |
| just type the following command: | |
| $ awk '{system("sleep 0.7");print}' file | |
| Do you want to read an html file (documentation file on the disk or | |
| from the web), you can use lynx or w3m to convert the html file on the | |
| fly to a readable text and pass it to awk stdin. | |
| $ w3m -dump doc/slsh/slshfun-2.html | awk '{system("sleep | |
| 0.7");print}' | |
| $ lynx -dump doc/slsh/slshfun-2.html | awk '{system("sleep | |
| 0.7");print}' | |
| $ w3m -dump https://dataswamp.org/~solene/ | awk '{system("sleep | |
| 0.7");print}' | |
| Maybe you want to read a man page? | |
| $ man awk | awk '{system("sleep 0.7");print}' | |
| If you want to pause the reading, you can use the true unix way, | |
| Ctrl+Z to send a signal which will stop the command and let it paused | |
| in background. You can resume the reading by typing `fg`. | |
| One could easily write a little script parsing parameters for setting | |
| the speed or handling files or url with the correct command. | |
| Notes: If for some reasons you try to use *lazyread*, fix the shebang | |
| in the file lesspipe.sh and you will need to call lazyread binary with | |
| the environment variable `LESSOPEN="|./lesspipe.sh %s"` (the path of | |
| the script if needed). Without this variable, you will have a very | |
| helpful error "file not found". |