#!/bin/bash # nmCont # Monitor basic network manager connection state for tint2 continous purposes. command -v nmcli >/dev/null 2>&1 || { >&2 echo "I need nmcli." ; exit 1; } main (){ # clear stuff for tint2 tooltip >&2 echo -en "\033[2J" # action state="$(nmcli -f state g | grep -v STATE | xargs)" # xargs works as a white space remover ^ if [ "$state" == "connected" ]; then icon="✓" elif [ "$state" == "asleep" ]; then icon="✗" else icon="?" fi echo "$icon" # end action # for tint2 tooltip >&2 echo "$state" } main # once (nmcli monitor) | while read -r do main # many times done # tint2 executor example # Executor nmCont #execp = new #execp_command =nmCont #execp_interval = 0 #execp_continuous = 1 #execp_lclick_command = nm-applet #execp_rclick_command = killall nm-applet