Now Reading
Introducing runst: Deal with desktop notifications neatly on Linux!

Introducing runst: Deal with desktop notifications neatly on Linux!

2023-03-05 06:01:10

runst is a lifeless easy notification daemon ???? On this publish, I am introducing the venture and giving totally different utilization examples that can enhance your Linux desktop expertise.


It’s simple that notifications turned an inescapable a part of our overly techy lives previously decade. More often than not, it’s missed how a easy alert dialog can fireplace totally different synapses within the human mind and allow us to really feel a sure manner. It’s actually magnificent that we generally do not see the truth that “notifying” is a type of communication and it’s deeply built-in into our lives at this level.

So let’s speak about Linux desktop and the way we will deal with notifications.

What? I hear you say “What the hell was that intro?”. Effectively, simply keep tight. It was undoubtedly not a trick to hook you to learn this weblog publish.

As in each interactive system, GNU/Linux additionally has other ways of dealing with notifications. First, let’s attempt to perceive what a notification is and what we have to truly work with it.

Desktop notifications are small, passive popup dialogs that notify the person of specific occasions in an asynchronous method.

In different phrases, notifications are dialogs which might be both proven on the display screen for a sure period of time and disappear or persist till person interplay. Cool!


Now, how will we work together with notifications? We clearly want some sort of inner communication protocol between processes to deal with messages from totally different purposes. At the moment, most Linux desktops rely on D-Bus for that function.

D-Bus is a message bus system, a easy manner for purposes to speak to 1 one other. Along with interprocess communication, D-Bus helps coordinate course of lifecycle; it makes it easy and dependable to code a “single occasion” utility or daemon, and to launch purposes and daemons on demand when their companies are wanted.

D-Bus has Desktop Notifications Specification which defines the usual implementation particulars for notification-related purposes. However, libnotify is extensively used for sending desktop notifications to a “notification daemon”. Each system wants a working notification daemon for dealing with notifications.

If you’re working D-Bus, you’ll be able to create a desktop notification utilizing the notify-send(1) command of libnotify:

$ notify-send "runst" "A lifeless easy notification daemon ????" --expire-time 3000

And you’ll question the desktop notifications real-time with working dbus-monitor(1):

$ dbus-monitor "interface='org.freedesktop.Notifications'"

This may lead to:

methodology name time=1677934706.650704 sender=:1.2392 -> vacation spot=:1.1673 serial=8 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   uint32 0
   string ""
   string "runst"
   string "A lifeless easy notification daemon ????"
   array [
   array [
      dict entry(
         string "urgency"
         variant             byte 1
      dict entry(
         string "sender-pid"
         variant             int64 442049
   int32 3000

With these in thoughts, let’s check out totally different notification daemon implementations.

Notification Daemons

Desktop environments have a built-in function for dealing with the notifications:

Cinnamon, Deepin, Enlightenment, GNOME, GNOME Flashback and KDE Plasma use their very own implementations to show notifications, and so they can’t be changed. Their notification servers are began mechanically on login to obtain notifications from purposes by way of D-Bus.

In that case, if we need to use a customized notification daemon, we want one thing standalone. This implies they may require a guide setup to work with Xorg/Wayland. Listed below are a couple of tasks:

  • wired – Light-weight notification daemon with extremely customizable format blocks.
  • mako – Light-weight notification daemon for Wayland.
  • dunst – Light-weight and customizable notification daemon.

(Editor’s observe: wow, they’re all light-weight!)

Amongst these tasks, by far the preferred notification daemon is dunst. For sure, I WAS a person of dunst. Additionally, the explanation why I wrote runst is principally… dunst.

So, what’s runst?

runsta lifeless easy notification daemon ????

runst demo I

runst is one more notification daemon implementation in Rust. It goals to be so simple as attainable whereas offering customizable options. The explanation why I wrote runst is just that:

I’ve been a person of dunst for a very long time. Nonetheless, they made some uncool breaking changes in v1.7.0 and it utterly broke my configuration. That day, I refused to replace dunst (I used to be too lazy to re-configure) and determined to put in writing my very own notification server utilizing Rust.

Therefore the identify. (dunst + rust = runst)

runst is initially designed to point out a easy notification window. On prime of that, it combines customization-oriented and semi-innovative options. The way in which that I take advantage of runst is fairly easy, it is simply an overlay on prime of i3status bar:

runst demo II

Nonetheless, there are numerous cool issues that you are able to do with runst.

Let’s undergo its options with utilization examples.

(runst is configured with a single configuration file. You’ll be able to take a look at the defaults here.)

Customized window

You’ll be able to customise the notification popup textual content, colour and dimensions. For instance:

    geometry = "312x184+1078+354" # `slop -k`
    font = "Monospace 10"
    template = """
    [{{app_name}}] <b>{{abstract}}</b>
    {% if physique %} {{physique}}{% endif %} 
    {% if now(timestamp=true) - timestamp > 60 %} 
        ({ humantime } in the past)
    {% endif %}
    {% if unread_count > 1 %} ({{unread_count}}){% endif %}

    background = "#000000"
    foreground = "#aaaaaa"
    textual content = "regular"

Within the configuration above, we configured the notification window dimensions, colours (for the conventional urgency), font, and the message template.

Now let’s take a better have a look at the template:

See Also

[{{app_name}}] <b>{{abstract}}</b>
{% if physique %} {{physique}}{% endif %} 
{% if now(timestamp=true) - timestamp > 60 %} 
    ({ humantime } in the past)
{% endif %}
{% if unread_count > 1 %} ({{unread_count}}){% endif %}

runst makes use of the next context for the template variables:

  "app_name": "runst",
  "abstract": "instance",
  "physique": "it is a notification ????",
  "urgency": "regular",
  "unread_count": 1,
  "timestamp": 1672426610

So we are going to find yourself with notifications like this:

  • [runst] instance it is a notification ????

  • [runst] instance it is a notification ???? (3m 2s in the past)

    • (whereas viewing an outdated notification)
  • [runst] instance it is a notification ???? (2)

    • (when there are 2 extra unread notifications)
  • [runst] instance

With this Tera-powered template, you’ll be able to customise the notification textual content as you want.

Customized instructions

You’ll be able to run customized OS instructions based mostly on urgency ranges and the notification contents.

Think about you need to carry out a process whenever you obtain a vital notification from a selected utility:

custom_commands = [
  { filter = '{ "app_name":"important-app","body":"^delete.*" }', command = '' },

Or perhaps you merely need to play a customized notification sound:

custom_commands = [
  { command = 'aplay notification.wav' },

Or perhaps you need a Gotify notification in your totally different units when somebody says hello in any chatting utility matched by the regex:

custom_commands = [
  { filter = '.*chat$","body":"^hello.*" ', command = 'gotify push -t "{{app_name}}" "someone said hi!"' },
  { filter = '{ "app_name":"matrix","body":"^hey.*" }', command = 'gotify push -t "{{app_name}}" "{{body}}"' }

See extra examples here.

Auto clear

Usually, if you would like the notifications to vanish after e.g. 3 seconds, you are able to do this:

timeout = 3

If the timeout shouldn’t be specified by the sender, the low urgency notifications might be closed after 3 seconds. You’ll be able to set timeout to 0 for unexpiring notifications.

However, if you would like the notifications to vanish as you end studying them, you should use the next possibility:

auto_clear = true

If this selection is about to true, the estimated learn time of the notification contents is calculated and it’s used because the timeout for closing the notification. So if it takes 5 seconds to learn the notification, it can disappear after 5 seconds.


There are different options that aren’t talked about on this publish so undoubtedly take a look at the venture’s residence web page:

I am utilizing runst each day and including new options as new concepts rush by means of my thoughts so suggestions could be very welcome! It’s nonetheless a bit barebone :>

See you within the subsequent venture! ????

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top