0

I want to execute a command periodically and based on its output to have a visual indication of its last return value (0: green, non-zero: red).

e.g. by using the command below I can check whether my vpn connection is still alive and healthy. protected-node is only accessible through vpn, so if vpn is unhealthy or down it will return non-zero.

nc -w5 -z vpn-only-accessible-node 80

So as said above, I am looking for a way to convert the return value of the command to visual indication in the statusbar or to some other always-visible area on my desktop.

I am using mate desktop.

2 Answers2

1

MATE applets, a fork of GNOME applets, should contain an applet named "Command" that periodically runs a command and displays output in the top panel. You should be probably able to add this applet to your panel right away (if not, you probably need to install mate-applets package).

While not fully what you want (you will get a textual indication instead of colors), you can use it to execute a script that runs your command and outputs either "OK" or "ERROR" (or any other text that suits you) depending on the return code.

enter image description here

raj
  • 11,409
1

Using notify-send, you can always do something like this:

while sleep 5
  do
    nc -w5 -z vpn-only-accessible-node 80 && \
    notify-send --icon=network-wired "OK" "OK" || \
    notify-send --icon=network-error "ERR" "Error"
    done

... or in a command string that you can run by providing it as a command in e.g. startup applications so that it automatically runs at user desktop login ... Like this:

/bin/bash -c 'while sleep 5; do nc -w5 -z vpn-only-accessible-node 80 && notify-send --icon=network-wired "OK" "OK" || notify-send --icon=network-error "ERR" "Error"; done'

Either of the above will run your command every five seconds and send you a visual desktop notification that is different in appearance and in message.

Raffa
  • 34,963