2

I've coded a Bash script for Kobo eReaders (https://github.com/tux-linux/Kobo-network-display-viewer) that displays a Linux-based computer screen on it. Here's a rough resume of how it works:
1. Gnome-screenshot takes real-time screenshots of the screen, which are put in /tmp and are constantly replaced.
2. Screenshot is sent via SCP, SSH to the /tmp directory of the Kobo, which is hosting a small Linux system.
3. I use a library to display the image on the screen: https://github.com/NiLuJe/FBInk
4. The process starts all over again, leading to constant (as constant as I could write it to be) image update on the eInk screen.

Well, that seems OK. But the problem I have is that eInk screen have a lifespan. And when an eInk screen constantly updates, second after second, an image on the screen, at some point it will inevitably (I think) cause some wear. But a big good thing about these screen is that if you leave a still image on it, it will not wear, except for the time it takes to display it.
So, what I'd like to do is to 'trap' or 'pause' the 'while' process (the code is below) when the host machine's screenshots are the same, to still display the image on the screen (which will stay there because of the eInk screen), but leave it there and not update it until 'diff' or a command like that finds a difference in it.

I'm little noob in Bash programming, so any help would be greatly appreciated. Here's the code:

while :; do read -r -p 'IP: ' ip && break; done
while :; do read -r -p "Your Kobo device screen width resolution: " width && break; done
while :; do read -r -p "Your Kobo device screen height resolution: " height && break; done
    sshpass -p test ssh root@$ip 'watch -n 30 "fbink -H -k -f | tee -a output.txt" &>/dev/null &'
    while true; do gnome-screenshot -p --file=/tmp/continuous.png && sshpass -p test scp /tmp/continuous.png root@$ip:/tmp && sshpass -p test ssh root@$ip 'fbink -g file=/tmp/continuous.png,w='$width',h='$height''; done

FYI, the 'fbink -k -f' thing is to refresh the screen every 30 seconds.
Thanks for your time!

  • 1
    Insert a `sleep` somewhere, e.g. `sleep 0.250`. –  Aug 25 '20 at 15:21
  • 1
    I see 2 underlying Qs here 1) *"when the ... screenshots are the same"* ; 2) *"leave it there and not update it until the mouse moves, or the hour display changes on the computer.*. Is that correct? Does your current code solve #1? Are you really looking for ideas about #2? If so, that seems very complicated. Do you plan to use the same software to "diff" the images for *"the hour display changes"* and separately use someother mechanism to *"until the mouse moves"* ? None of these are easy, and none of them are really a feature you'll find in shell scripting. Try to rephrase your problem above – shellter Aug 25 '20 at 15:48
  • Done. Feel free to ask me other questions if you are in doubt. – Nicolas Mailloux Aug 25 '20 at 15:53
  • 1
    If you take a checksum (`md5sum` / etc) of two "identical" screenshots, do they match? If they don't match, do a binary diff: Where are the differences? Are they only in a header? Can you just skip the header and _then_ do a byte-by-byte comparison? – Charles Duffy Aug 25 '20 at 15:56
  • 1
    BTW, I'm not sure this question has anything to do with "pausing" loops. It might be better to ask how to compare two images, or how to _skip_ a command if one image matches a previous one, or so forth. But either way -- the problem you're trying to solve could stand to be deconstructed more, such that what you ask here is as _narrow_ and _specific_ as possible. – Charles Duffy Aug 25 '20 at 15:58
  • Sorry, but I don't see that you made that much difference in your Q. I'd recommend experimenting with CD's ideas, especially `md5sum` and binary `diff`. Else you'll have to find a utility program designed specifically to compare `.png` and/or other image files. You might find some help from the `iconv` utility. Good luck! – shellter Aug 27 '20 at 21:54

0 Answers0