#!/bin/bash set -Eeuo pipefail test -f ~/.irssi/activity_file || exit 1 DIRECT_ONLY="" while getopts D opt; do case $opt in D) DIRECT_ONLY="1" ;; esac done has_activity() { awk -v s=$1 -F, \ 'BEGIN { c=1 } { if ($2 == s) c=0 } END { exit c }' \ ~/.irssi/activity_file } print() { printf "#[fg=green][#[fg=%s]M#[fg=green]]" "$1" exit 0 } if has_activity 3; then print "red" fi if [[ -z "$DIRECT_ONLY" ]] && has_activity 2; then print "white" fi