Reputation: 23221
I have some codes that automatically generate Machine Learning plots on a server, sending plots to IoT clients at appropriate times for display.
The data pipeline works. However, my attempt to update the image in near real-time when a new plot is push is not working.
Currently my approach is:
user@client:~/data_viz $ watch -n3 feh -F plot0.png --zoom 200
where feh
is some arbitrary lightweight Linux image viewer.
The problem is that even when the file (plot0.png
) is overwritten successfully the viewer does not update until you kill it and restart it.
Update: I've acheived the world's worst version of this with the Bash approach below. The only problem now is that it flashes the desktop every second and will undoubtedly cause a seizure if I don't fix that...
$ watch -n2 sudo bash watch.sh
where watch.sh
is
#!/bin/bash
i="0"
while [ $i -lt 4 ]
do
pkill feh
sleep 1
feh -F plot0.png --zoom 200&
sleep 1
pkill feh
done
There also seems to be no way to actually break the infinite loop even with Esc and ctrl+c. I want the loop to be infinite, but I also would prefer to be able to interrupt it when I have to.
Upvotes: 1
Views: 1051
Reputation: 84609
While feh
, like most image viewers/editors, does not watch the image-file for changes and automatically reload if changes occur, it does provide the -R, --reload <int>
option that will cause feh
to reload the image after the number of seconds specified as <int>
transpire. For example:
feh --reload 5 image.png
will cause feh
to reload image.png
every 5
seconds. man 1 feh
explains:
-R, --reload <int> Reload filelist and current image after int seconds. Useful for viewing HTTP webcams or frequently changing directories. (Note that the filelist reloading is still experimental.) If an image is removed, feh will either show the next one or quit. However, if an image still exists, but can no longer be loaded, feh will continue to try loading it.
Upvotes: 2