Notification Management; or, Trying to Live Without Distractions

The way most operating systems deliver notifications by default has always bothered me. Notifications are often distracting, since they pop up suddenly on the screen and demand you do something right now. They also don’t go away until you click on them, but after that they are gone forever. This frequently resulted in me being distracted by the notification, distractingly clicking it away, resulting in neither knowing what I did before nor what the notification that I clicked away was about. Even worse than that is missing notifications because they pop up on the “wrong” screen.

For me notifications should ideally have the following properties:

  • Stay somewhere until they are manually dismissed (even after a reboot)
  • Not be on the screen all the time
  • Be sorted in reverse chronological order
  • Be easily accessible (via a shortcut or the GUI)

Some OSes get this down quite well. One that comes to mind is Windows 10/11. The one that does this the best (in my opinion) is Android (looking at you, Apple. Whats up with the weird notification pop-ups???). The current state on Linux is a far cry from that reality.

When I found about Rofication I thought this tool was written for me personally. The tool is quite bare-bones, but it brings everything that I need to make a functional “notification center” in Sway.

My Setup

Rofication consists of 2 parts, the daemon and an example GUI client. After installing it, using it in sway is just the matter of autostarting it and adding an appropriate keybind:

exec rofication-daemon.py
bindsym $mod+n exec rofication-gui.py

After that we are ready to receive and view our notifications. They are persisted across reboots and can be interacted with via different key bindings (eg. Alt+s to dismiss).

This gets us up and running, but are missing one more component: a widget that shows us how many notifications we have. Ideally, it should also change color if we have notifications, so that we can ascertain this at a glance.

One part of this is already provided by the original author, in the form of rofication-statusi3blocks.py. This simply prints out the number of notifications and could be easily integrated into a widget. To make our widget change color depending on the number of notifications, we need to extend this a bit. The bar I’m using (Waybar), expects a simple JSON object in the following form:

{
  "text": "$text",
  "alt": "$alt",
  "tooltip": "$tooltip",
  "class": "$class",
  "percentage": "$percentage"
}

NB: Waybar expects this to be in a single line, I just formatted it this way for demonstration purposes.

To make this work, we pass the name of a CSS class, and change the waybar config to make that class use a specific colour. Using jq, it is quite simple to “extend” the original script to output JSON instead:

#!/usr/bin/env sh

rofication-statusi3blocks.py | \
    jq --unbuffered \
    --compact-output \
    '{"text": .,"alt": ., "tooltip": "notifications", "class": (if . > 0 then "multiple" else "none" end)}'

After that, we can add a new module to our waybar-config:

{
    "custom/rofication": {
        "format": "{} ",
        "exec": "notif",
        "interval": 5,
        "return-type": "json",
        "on-click": "rofication-gui.py"
    }
}

Add the appropriate CSS code as well:

#custom-rofication.multiple {
    background-color: #eb4d4b;
}

After that we should have a working setup!

I’ve been using this setup for quite a while now and I’m really happy with it. It is pretty much an ideal notification setup for me. The only thing I’m missing is a timestamp for the specific notifications. Maybe this is possible, but I have not found an option to enable this yet.

Hope you enjoyed reading this article!


Articles from blogs I read - Generated by openring