irssi, it is easy to enable bells on notifications (mentions, or direct messages) with the following command:
/SET beep_msg_level MSGS HILIGHT DCCMSGS
However; this does just that. It sends beeps on highlights, and private messages — regardless of terminal state. Is there a way to continue to receive beeps, but only if the terminal window is not in focus? It does not make much sense to receive beeps in a private chat if you're already actively chatting.
I am using Bash on macOS.