I am generally a fan of the popup notifications. However, i have them activated for gmail, whatsapp, the forum, and with KDE connect i receive notifications also from my phone…and sometimes (like when watching a movie or gaming) it is just too much. As a former ubuntu user i remember there was a toggle near the clock for the DND mode. XFCE also supports it, but i could not find an easy toggle, i had to open Settings-Notifications and toggle from there. So to reduce the 4 clicks needed to just 1, i created a little script to toggle it (i used the aur checking script from linus-aarchus as a model). I hope it will be useful to someone else too.
Actually, i made 2 variants of the script. The first one shows notifications. Big and colourful ones . Unfortunately since DND mode is hiding notifications, in order to show one, it has to be critical, and that has no timeout and stays until the user clicks it. So we have 2 clicks…
#!/usr/bin/env bash
#
# XFCE Do not disturb toggler - tooltip variant (click to hide)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# 2023-07-02
# Todor Uzunov
#
#check if on XFCE
if ! command -v xfconf-query > /dev/null; then
echo "This script is only for XFCE, sorry."
exit 1
fi
#check if libnotify is available
if ! [[ "$(which notify-send)" =~ (notify-send) ]]; then
echo ":: libnotify not found... install with sudo pacman -S libnotify"
exit 1
fi
#toggle DND
xfconf-query -c xfce4-notifyd -p /do-not-disturb -T
#read the new value
#sleep 0.2
dnd_status=$(xfconf-query -c xfce4-notifyd -p /do-not-disturb)
#notify
if [[ $dnd_status == true ]]
then
notify-send -u critical "DND toggled on" "<span color='#ff1000' font='28px'><i><b>Notifications OFF</b></i></span>"
else
notify-send -u normal "DND toggled off" "<span color='#57ff00' font='28px'><i><b>Notifications ON</b></i></span>"
fi
I was not very happy with that solution so i made a more subtle version - it shows an icon near the clock when DND is on. Note that this requires yad as a dependency, and kills yad at the end, so if you use yad for anything else you might want to edit the script.
#!/usr/bin/env bash
#
# XFCE Do not disturb toggler - notification icon variant
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# 2023-07-02
# Todor Uzunov
#
#check if on XFCE
if ! command -v xfconf-query > /dev/null; then
echo "This script is only for XFCE, sorry."
exit 1
fi
#check if yad is available
if ! [[ "$(which yad)" =~ (yad) ]]; then
echo ":: yad not found... install with sudo pacman -S yad"
exit 1
fi
#toggle DND
xfconf-query -c xfce4-notifyd -p /do-not-disturb -T
#read the new value
#sleep 0.2
dnd_status=$(xfconf-query -c xfce4-notifyd -p /do-not-disturb)
#notify with icon near the clock only if in DND mode
if [[ $dnd_status == true ]]
then
yad --notification --image="vcs-conflicting" --listen &
else
pkill yad
fi
In both cases, save the script in ~/.local/bin/ , make it executable, and create a launcher on the panel for it. I used the icon vcs-conflicting , since it is red and i hope it is in the standard set of icons. You can also assign a keyboard shortcut through the keyboard settings, but don’t use ctrl-alt-d - is is already assigned. I use the right side: rctrl-ralt-d.
And if you like me tend to turn DND on and forget it till next reboot, here is a slightly modified version of the script to detect it an show an icon on boot if DND is on - save the script with another name and add it to the startup scripts in Session settings.
#!/usr/bin/env bash
#
# XFCE Do not disturb status checker (displays an icon near the clock if DND is on)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# 2023-07-02
# Todor Uzunov
#
#check if on XFCE
if ! command -v xfconf-query > /dev/null; then
echo "This script is only for XFCE, sorry."
exit 1
fi
#check if yad is available
if ! [[ "$(which yad)" =~ (yad) ]]; then
echo ":: yad not found... install with sudo pacman -S yad"
exit 1
fi
#read the DND state
dnd_state=$(xfconf-query -c xfce4-notifyd -p /do-not-disturb)
#notify with icon near the clock only if in DND mode
if [[ $dnd_state == true ]]
then
yad --notification --image="vcs-conflicting" --listen &
fi