Skip to content

Instantly share code, notes, and snippets.

@andreycizov
Created December 11, 2019 21:06
Show Gist options
  • Save andreycizov/738f80a16c9e401d6a9e77b863e67066 to your computer and use it in GitHub Desktop.
Save andreycizov/738f80a16c9e401d6a9e77b863e67066 to your computer and use it in GitHub Desktop.
Enable desktop notifications trigger urgent flag for your Slack running in Linux via Dunst filters
#!/bin/sh -ex
# THIS SCRIPT ASSUMES YOU DON'T HAVE A CUSTOM DUNST SETUP IN ~/.config/dunst/dunstrc!!!!!!
# https://geekoverdose.wordpress.com/2019/08/01/i3-window-manager-selectively-make-any-notification-urgent-urgency-flag-to-highlight-the-workspace/
mkdir -p ~/bin
DUNST=~/bin/dunst-urgent-notification
cat >$DUNST <<BEGIN
#!/bin/sh
wmctrl -r \$1 -b add,demands_attention
BEGIN
chmod +x $DUNST
mkdir -p ~/.config/dunst
DUNSTRC=~/.config/dunst/dunstrc
zcat /usr/share/doc/dunst/dunstrc.gz > $DUNSTRC
cat >>$DUNSTRC <<BEGIN
[slack]
appname = "Slack"
summary = "*"
# this is the filter criterion applied to the message, see below
# urgency = critical # those attributes could be used to set details of the message in the script called below
# format = "" # could be used to alter the popup text, see below
script = ~/bin/dunst-urgent-notification # this is the script that is called, see below
BEGIN
killall dunst; notify-send "Slack notifications now set up!"
Copy link

ghost commented Dec 12, 2019

wmctrl needs to be pre-installed before using this. also moving dunst-urgent-notification to ~/.config/dunst is more reasonable.

Copy link

ghost commented Dec 18, 2019

This has a bug where if you have an another window starting with "Slack..." that window is going to be marked as URGENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment