代码之家  ›  专栏  ›  技术社区  ›  Hack-R

使用watch每N秒更新Linux中显示的图像失败

  •  1
  • Hack-R  · 技术社区  · 8 年前

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

    数据管道工作正常。然而,当新的绘图被推送时,我试图在接近实时的情况下更新图像的尝试是不起作用的。

    目前我的方法是:

    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,似乎也无法真正中断无限循环。我希望循环是无限的,但我也希望能够在必要时中断它。

    1 回复  |  直到 8 年前
        1
  •  1
  •   David C. Rankin    8 年前

    feh -R, --reload <int> <int>

    feh --reload 5 image.png
    

    image.png 5 man 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.