3 ms·
If I understand correctly, you have a remote server with a logfile, and some markers in this log file tells you whether the build is in process or finished. I
by Galanwe 4y ago
If I understand correctly, you have a remote server with a logfile, and some markers in this log file tells you whether the build is in process or finished.
I would suggest you keep it simple and simply poll the logfile for the latest occurrence of either "Build started" or "Build finished" and display a pop-up for each case.
Very roughly that would look like:
while true
do
MATCH=$(ssh remote@host 'cat /logfile' | grep -P 'started|finished' | tail -1)
case "$MATCH" in
*started*)
notify-send "Build started"
;;
*finished*)
notify-send "Build finished"
;;
esac
sleep 1s
done
That's dirty bash written in an HN comment on my phone, but the idea is here. It's a bit wasteful to initiate ssh sessions so often, so you could improve it with a single "ssh remote@host tail -f /logfile", pipe that to "grep", then to a while read, but I left that as an exercise.
There is some option to notify-send so that pop-ups replace one another instead of creating new ones.
- asdfman123 4y agoI should have clarified I’m usually looking at another tab in tmux. Any way to pop up there?
- jxf 4y agoYou can ask tmux to update the window status — for instance to show red or green based on the exit code of the last command. Example here: https://unix.stackexchange.com/a/597367/63035 https://unix.stackexchange.com/a/597367/63035
- asdfman123 3y agoNice! I was able to do just that, with a solution like the one you wrote, except I'm grepping a local (instead of remote) log, and changing the status bar color based on log output. Was exactly what I wanted, thanks.