Pausing dunst while zoom screen sharing

I wrote a small script/blocklet to mute the dunst notifications while I’m sharing my screen over zoom. To prevent accidentally giving confidential information to other people e.g Slack or Mattermost messages.

I developed this as a blocklet for my i3wm (tiling window manager) status bar called i3blocks. It tries to find a specific window on your desktop, called “as_toolbar”, which represents that you share your screen.

If the window could be found, the dunst service will be paused and you will be notified over dunst that “Sharing mode” is activated. Upcoming dunst messages will be not removed so that by stop sharing your screen, all the messages will be shown.

It also shows a small bell and slashed bell icon (in my case) in the status bar. You can change it to any icon or text you like.
PS: Most likely the icon will shown as  in your editor

Zoom Dunst Blocklet

I named it “zoom.sh”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

DUNST_TIMEOUT=3 # duration in seconds
DUNST_URGENCY=low # low, normal or critical

xwininfo -name as_toolbar >/dev/null 2>&1
if [ $? -eq 0 ]; then
if ! [ -f "/tmp/i3zoom.lock" ]; then
touch /tmp/i3zoom.lock
notify-send -u ${DUNST_URGENCY} -t ${DUNST_TIMEOUT}000 Zoom "Sharing mode activated"
sleep ${DUNST_TIMEOUT}
notify-send DUNST_COMMAND_PAUSE
echo "<span foreground=\"#FF0000\"></span>"
else
echo "<span foreground=\"#FF0000\"></span>"
fi

else
if [ -f "/tmp/i3zoom.lock" ]; then
rm /tmp/i3zoom.lock
notify-send DUNST_COMMAND_RESUME
fi
echo "<span foreground=\"#00FF00\"></span>"
fi

Integration in i3blocks config

1
2
3
4
[zoom]
command=$HOME/.config/i3blocks/blocks/zoom.sh
interval=5
markup=pango