开发者

Updating content of a zenity window

开发者 https://www.devze.com 2023-03-04 12:47 出处:网络
I\'m trying to making a small monitor to a program called showbf that print an updating itself every a certain amount of time.

I'm trying to making a small monitor to a program called showbf that print an updating itself every a certain amount of time.

my best try is the following

ssh user@server.foo "exit" 
if [ $? -ne 0 ]
then 
    ssh-add < /dev/null
fi

while true
do
resources=$(ssh user@server.foo "showbf")
if (echo "$resources" | grep -q "[0-9] procs") 
then
    echo $(echo "$resources" | awk '/[0-9] procs/ {print $1,"for",$5}')
else 
    echo "No procs available."
fi

if [[ $? == 0 ]] || [[ $? == 1 ]]
then
    exit 0
fi
sleep 1
done | zenity --text-info --height=200 --width=300 \
    --title "Resources available for immediate use (showbf)" 

I really don't like it because it appends the results to the previews. 开发者_如何学运维It becomes really messy. I'd like to use something like zenity --list (the results are 2 colums, num of proc available and walltime). But once zenity reads the data it does not update its contents. Any ideas??

Using while loops to recreate windows is not what I want because the new windows is replaced in the center of the screen.

Many thanks Salvatore


If you haven't already worked this out, you really should check out yad, a fork of zenity which is being actively improved. I only just installed it tonight (after bashing my head in trying to work around a bug in zenity), but I wouldn't be surprised if it could do what you want. I noticed it has a --tail option, for example. It's in fedora's repos, and that page has links to deb packages.


Seven years late but better than never. This yad support forum addresses the issue for some people:

Re: [yad] Re: Can a yad window update itself? Exactly what Joe stated but, you have to use:

Child(yad -tail --> *.log --> Yad Parent(yad --text-info )

displayed and auto scrolling. This is not possible with zenity. See my below video:

https://www.youtube.com/watch?v=stPAWGXQyLY


Instead of using zenity, why not bring up an xterm with a "watch" command it in which gets the necessary information. Something like:

xterm -g 80x40+100+100 -e "watch ssh user@server.foo showbf"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号