使用手表每 N 秒更新 linux 中显示的图像失败

Use of watch to update image displayed in linux every N seconds fails

我有一些代码可以在服务器上自动生成机器学习图,并在适当的时候将图发送到物联网客户端进行显示。

数据管道工作正常。但是,我尝试在推送新情节时近乎实时地更新图像,但没有奏效。

目前我的做法是:

user@client:~/data_viz $ watch -n3 feh -F plot0.png --zoom 200

其中 feh 是一些任意的轻量级 Linux 图像查看器。

问题是,即使文件 (plot0.png) 被成功覆盖,查看器也不会更新,直到您杀死它并重新启动它。

更新:我用下面的 Bash 方法实现了世界上最糟糕的版本。现在唯一的问题是它每秒都会闪烁桌面,如果我不修复它无疑会导致癫痫发作...

$ watch -n2 sudo bash watch.sh

其中 watch.sh

#!/bin/bash
i="0"    
while [ $i -lt 4 ]
do
pkill feh
sleep 1
feh -F plot0.png --zoom 200&
sleep 1
pkill feh
done

即使使用 Esc 和 ctrl+c,似乎也无法真正打破无限循环。我希望循环是无限的,但我也希望能够在必要时中断它。

虽然 feh 与大多数图像 viewers/editors 一样,不会监视图像文件的变化并在发生变化时自动重新加载,但它确实提供了 -R, --reload <int> 选项,这将导致feh 在指定为 <int> 的秒数后重新加载图像。例如:

feh --reload 5 image.png

将导致 feh5 秒重新加载 image.pngman 1 feh 说明:

-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.