#!/bin/bash -eu lines=$(who | grep pts | grep -Ev "\(:pts") if [[ -z "$lines" ]]; then printf '{"text":"No SSH connections", "tooltip":"No SSH connections", "class":"normal"}' else line_count=$(echo "$lines" | wc --lines) lines="${lines/$'\n'/\\\\n}" printf '{"text":"'"$line_count"' SSH connection(s)", "tooltip":"'"$lines"'", "class":"active"}' fi