A simple GTK based notification daemon for SwayWM
Go to file
Erik Reider 9c999db4b9 Fixed menubar widget + other fixes
- Tweaked default style to match the other widgets
- Improved the MAN page doc
- Fixed the alignment not working in GTK4
2023-07-04 21:00:00 +02:00
.github Added rpmlint workflow 2023-05-30 12:34:31 +02:00
assets Panel image is correct image 2021-11-17 20:44:12 +01:00
build-aux/meson Replaced state cacher with gsettings 2022-06-19 14:01:22 +02:00
build-scripts corrected misspellings of the word "notification" (#287) 2023-06-26 10:58:09 +02:00
completions corrected misspellings of the word "notification" (#287) 2023-06-26 10:58:09 +02:00
data Initial work 2023-06-27 21:37:41 +02:00
man Fixed menubar widget + other fixes 2023-07-04 21:00:00 +02:00
services Fixes #152 2022-08-15 18:47:43 +02:00
src Fixed menubar widget + other fixes 2023-07-04 21:00:00 +02:00
.gitignore Initial work 2023-06-27 21:37:41 +02:00
.uncrustify.cfg Updated .uncrustify.cfg to work with uncrustify 0.75 2023-02-09 20:49:16 +01:00
.vala-lint.conf Line length lint now is error 2022-05-06 13:15:00 +02:00
COPYING Initial commit 2021-07-27 21:58:52 +02:00
meson_options.txt Man pages (#104) 2022-04-02 17:52:35 +02:00
meson.build Initial work 2023-06-27 21:37:41 +02:00
README.md Update i3status-rs Example format syntax for 0.31.0 (#283) 2023-06-14 17:38:41 +02:00

SwayNotificationCenter

Check PKGBUILD builds for Arch. Check build for Fedora. Check build for latest Ubuntu LTS. Linting

A simple notification daemon with a GTK gui for notifications and the control center

Note: SwayNotificationCenter only supports Desktops / Window Managers that support wlr_layer_shell_unstable_v1 like Sway or anything wlroots based

Note 2: SwayNotificationCenter does not support third-party GTK3 themes and is only tested with the default GTK Adwaita theme. Usage of any third-party theme might require extra tweaks to the default CSS style file

Table of Contents

Screenshots

Screenshot of desktop notification

Screenshot of panel

Want to show off your sick config?

Post your setup here: Config flex 💪

Features

  • Keyboard shortcuts
  • Notification body markup with image support
  • Inline replies
  • A panel to view previous notifications
  • Show album art for notifications like Spotify
  • Do not disturb
  • Inhibiting notifications through DBUS or client
  • Restores previous Do not disturb value after restart
  • Click notification to execute default action
  • Show alternative notification actions
  • Copy detected 2FA codes to clipboard
  • Customization through a CSS file
  • Trackpad/mouse gesture to close notification
  • The same features as any other basic notification daemon
  • Basic configuration through a JSON config file
  • Hot-reload config through swaync-client
  • Customizable widgets

Available Widgets

These widgets can be customized, added, removed and even reordered

  • Title
  • Do Not Disturb
  • Notifications (Will always be visible)
  • Label
  • Mpris (Media player controls for Spotify, Firefox, Chrome, etc...)
  • Menubar with dropdown and buttons
  • Button grid
  • Volume slider using PulseAudio
  • Backlight slider

Planned Features

  • Slick animations 😎
  • Other build scripts than a PKGBUILD (debian and/or RHEL systems)

Install

Arch

The package is available on the AUR:

Fedora

The package is available on COPR:

dnf copr enable erikreider/SwayNotificationCenter
dnf install SwayNotificationCenter

Fedora Silverblue (and other rpm-ostree variants)

The package can be layered over the base image after adding the Copr repo as an ostree repo:

ostree remote add SwayNotificationCenter https://download.copr.fedorainfracloud.org/results/erikreider/SwayNotificationCenter/fedora-$releasever-$basearch/
rpm-ostree install SwayNotificationCenter

Gentoo

An unofficial ebuild is available in GURU

eselect repository enable guru
emaint sync -r guru
emerge --ask gui-apps/swaync

OpenSUSE Tumbleweed

sudo zypper install SwayNotificationCenter

Ubuntu

Lunar and later:

sudo apt install sway-notification-center

Debian

Bookworm and later:

sudo apt install sway-notification-center

Other

meson build
ninja -C build
meson install -C build

Sway Usage

# Notification Daemon
exec swaync

# Toggle control center
bindsym $mod+Shift+n exec swaync-client -t -sw

Run

To start the daemon (remember to kill any other notification daemon before running)

./build/src/swaync

To toggle the panel

./build/src/swaync-client -t

To reload the config

./build/src/swaync-client -R

To reload css after changes

./build/src/swaync-client -rs

Control Center Shortcuts

  • Up/Down: Navigate notifications
  • Home: Navigate to the latest notification
  • End: Navigate to the oldest notification
  • Escape/Caps_Lock: Close notification panel
  • Return: Execute default action or close notification if none
  • Delete/BackSpace: Close notification
  • Shift+C: Close all notifications
  • Shift+D: Toggle Do Not Disturb
  • Buttons 1-9: Execute alternative actions
  • Left click button / actions: Activate notification action
  • Right click notification: Close notification

Configuring

The main config file is located in /etc/xdg/swaync/config.json. Copy it over to your .config/swaync/ folder to customize without needing root access. See swaync(5) man page for more information

To reload the config, you'll need to run swaync-client --reload-config

The main CSS style file is located in /etc/xdg/swaync/style.css. Copy it over to your ~/.config/swaync/ folder to customize without needing root access.

Tip: running swaync with GTK_DEBUG=interactive swaync will open a inspector window that'll allow you to see all of the CSS classes + other information.

Notification Inhibition

Notifications can be inhibited through the provided swaync-client executable or through the DBus interface org.erikreider.swaync.cc.

Here's an example of notification inhibition while screen sharing through xdg-desktop-portal-wlr

# xdg-desktop-portal-wlr config
[screencast]
exec_before=swaync-client --inhibitor-add "xdg-desktop-portal-wlr"
exec_after=swaync-client --inhibitor-remove "xdg-desktop-portal-wlr"

Scripting

Scripting rules and logic:

. Only one script can be fired per notification . Each script requires exec and at least one of the other properties . All listed properties must match the notification for the script to be ran . If any of the properties doesn't match, the script will be skipped . If a notification doesn't include one of the properties, that property will be skipped · If a script has run-on set to action, the script will only run when an action is taken on the notification

More information can be found in the swaync(5) man page

Notification information can be printed into a terminal by running G_MESSAGES_DEBUG=all swaync (when a notification appears).

Config properties:

{
  "scripts": {
    "example-script": {
      "exec": "Your shell command or script here...",
      "app-name": "Notification app-name Regex",
      "summary": "Notification summary Regex",
      "body": "Notification body Regex",
      "urgency": "Low or Normal or Critical",
      "category": "Notification category Regex"
    }
  }
  other non scripting properties...
}

config.json example:

{
  "scripts": {
    // This script will only run when Spotify sends a notification containing
    // that exact summary and body
    "example-script": {
      "exec": "/path/to/myRickRollScript.sh",
      "app-name": "Spotify"
      "summary": "Never Gonna Give You Up",
      "body": "Rick Astley - Whenever You Need Somebody"
    }
  }
  other non scripting properties...
}

Disable scripting

To completely disable scripting, the project needs to be built like so:

meson build -Dscripting=false
ninja -C build
meson install -C build

i3status-rs Example

Note

Ths requires i3status-rs version 0.31.0+

i3status-rs config

[[block]]
block = "notify"
format = " $icon {($notification_count.eng(w:1)) |}"
driver = "swaync"
[[block.click]]
button = "left"
action = "show"
[[block.click]]
button = "right"
action = "toggle_paused"

Waybar Example

This example requires NotoSansMono Nerd Font to get the icons looking right

Waybar config

  "custom/notification": {
    "tooltip": false,
    "format": "{icon}",
    "format-icons": {
      "notification": "<span foreground='red'><sup></sup></span>",
      "none": "",
      "dnd-notification": "<span foreground='red'><sup></sup></span>",
      "dnd-none": "",
      "inhibited-notification": "<span foreground='red'><sup></sup></span>",
      "inhibited-none": "",
      "dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>",
      "dnd-inhibited-none": ""
    },
    "return-type": "json",
    "exec-if": "which swaync-client",
    "exec": "swaync-client -swb",
    "on-click": "swaync-client -t -sw",
    "on-click-right": "swaync-client -d -sw",
    "escape": true
  },

Waybar css file

#custom-notification {
  font-family: "NotoSansMono Nerd Font";
}

Alternatively, the number of notifications can be shown by adding {} anywhere in the format field in the Waybar config

  "custom/notification": {
    "format": "{} {icon}",
    ...
  },