2023-05-11 22:53:41 +03:00
SwayNotificationCenter
======================
2021-07-28 20:32:43 +03:00
2023-03-03 14:51:43 +03:00
[![Check PKGBUILD builds for Arch. ](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/PKGBUILD-builds.yml/badge.svg )](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/PKGBUILD-builds.yml)
2022-11-23 20:06:15 +03:00
[![Check build for Fedora. ](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/fedora-build.yml/badge.svg )](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/fedora-build.yml)
[![Check build for latest Ubuntu LTS. ](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/ubuntu-build.yml/badge.svg )](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/ubuntu-build.yml)
2022-05-05 23:41:37 +03:00
[![Linting ](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/linting.yml/badge.svg )](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/linting.yml)
2021-12-27 20:08:05 +03:00
A simple notification daemon with a GTK gui for notifications and the control center
2021-07-28 20:32:43 +03:00
2023-05-11 22:53:41 +03:00
*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*
2024-02-10 19:12:27 +03:00
## Demo
https://github.com/ErikReider/SwayNotificationCenter/assets/35975961/93ff072f-e653-4064-8200-1c90590b83ef
![Screenshot of panel ](./assets/panel.png )
2023-05-11 22:53:41 +03:00
Table of Contents
=================
* [Want to show off your sick config? ](#want-to-show-off-your-sick-config )
* [Features ](#features )
* [Available Widgets ](#available-widgets )
* [Planned Features ](#planned-features )
* [Install ](#install )
* [Arch ](#arch )
* [Fedora ](#fedora )
* [Fedora Silverblue (and other rpm-ostree variants) ](#fedora-silverblue-and-other-rpm-ostree-variants )
* [Gentoo ](#gentoo )
* [OpenSUSE Tumbleweed ](#opensuse-tumbleweed )
* [Ubuntu ](#ubuntu )
* [Debian ](#debian )
2023-08-14 21:27:15 +03:00
* [Guix ](#guix )
* [rde ](#rde )
2023-05-11 22:53:41 +03:00
* [Other ](#other )
* [Sway Usage ](#sway-usage )
* [Run ](#run )
* [Control Center Shortcuts ](#control-center-shortcuts )
* [Configuring ](#configuring )
2023-11-13 02:52:26 +03:00
* [Toggle Buttons ](#toggle-buttons )
2023-05-11 22:53:41 +03:00
* [Notification Inhibition ](#notification-inhibition )
* [Scripting ](#scripting )
* [Disable scripting ](#disable-scripting )
* [i3status-rs Example ](#i3status-rs-example )
* [Waybar Example ](#waybar-example )
2022-08-17 18:45:34 +03:00
2022-11-23 20:04:41 +03:00
## Want to show off your sick config?
Post your setup here: [Config flex 💪 ](https://github.com/ErikReider/SwayNotificationCenter/discussions/183 )
2021-07-28 20:32:43 +03:00
## Features
2023-12-12 23:02:46 +03:00
- Grouped notifications
2021-08-02 19:39:53 +03:00
- Keyboard shortcuts
2021-08-07 16:44:32 +03:00
- Notification body markup with image support
2023-05-29 16:08:51 +03:00
- Inline replies
2021-07-28 20:32:43 +03:00
- A panel to view previous notifications
2021-07-29 22:38:42 +03:00
- Show album art for notifications like Spotify
2021-07-29 22:37:40 +03:00
- Do not disturb
2023-02-23 23:41:08 +03:00
- Inhibiting notifications through DBUS or client
2022-05-08 20:42:04 +03:00
- Restores previous Do not disturb value after restart
2021-07-30 19:20:29 +03:00
- Click notification to execute default action
- Show alternative notification actions
2023-02-19 20:32:40 +03:00
- Copy detected 2FA codes to clipboard
2021-07-31 01:37:11 +03:00
- Customization through a CSS file
2021-09-16 14:38:35 +03:00
- Trackpad/mouse gesture to close notification
2021-07-28 20:32:43 +03:00
- The same features as any other basic notification daemon
2021-10-13 14:19:38 +03:00
- Basic configuration through a JSON config file
- Hot-reload config through `swaync-client`
2022-08-03 18:02:09 +03:00
- Customizable widgets
## Available Widgets
These widgets can be customized, added, removed and even reordered
- Title
- Do Not Disturb
- Notifications (Will always be visible)
- Label
2022-11-07 14:19:29 +03:00
- Mpris (Media player controls for Spotify, Firefox, Chrome, etc...)
2023-02-09 21:22:29 +03:00
- Menubar with dropdown and buttons
- Button grid
2023-02-12 18:16:33 +03:00
- Volume slider using PulseAudio
2023-02-22 20:16:19 +03:00
- Backlight slider
2021-07-28 20:32:43 +03:00
2021-07-29 11:09:07 +03:00
## Planned Features
- Slick animations 😎
2021-08-01 01:18:12 +03:00
- Other build scripts than a PKGBUILD (debian and/or RHEL systems)
2021-07-29 11:09:07 +03:00
2021-07-28 20:32:43 +03:00
## Install
2023-05-11 22:53:41 +03:00
### Arch
2022-12-17 17:12:31 +03:00
2022-01-09 02:29:32 +03:00
The package is available on the AUR:
2022-01-09 02:46:45 +03:00
2022-01-09 02:29:32 +03:00
- [swaync ](https://aur.archlinux.org/packages/swaync/ )
- [swaync-git ](https://aur.archlinux.org/packages/swaync-git/ )
2021-07-30 23:36:50 +03:00
2023-05-11 22:53:41 +03:00
### Fedora
2022-12-17 17:12:31 +03:00
2022-07-23 17:31:59 +03:00
The package is available on COPR:
2022-01-16 20:47:45 +03:00
2022-04-02 18:52:35 +03:00
```zsh
2022-07-23 17:05:51 +03:00
dnf copr enable erikreider/SwayNotificationCenter
2022-01-16 20:47:45 +03:00
dnf install SwayNotificationCenter
```
2023-05-11 22:53:41 +03:00
### Fedora Silverblue (and other rpm-ostree variants)
2022-12-17 17:12:31 +03:00
2023-04-27 21:37:12 +03:00
The package can be layered over the base image after adding the Copr repo as an ostree repo:
2022-12-17 17:12:31 +03:00
2022-09-20 22:43:55 +03:00
```zsh
2023-07-08 13:06:38 +03:00
sudo curl -sL -o /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:erikreider:SwayNotificationCenter.repo https://copr.fedorainfracloud.org/coprs/erikreider/SwayNotificationCenter/repo/fedora-$(rpm -E %fedora)/erikreider-SwayNotificationCenter-fedora-$(rpm -E %fedora).repo
2022-09-20 22:43:55 +03:00
rpm-ostree install SwayNotificationCenter
```
2023-05-11 22:53:41 +03:00
### Gentoo
2022-12-17 17:12:31 +03:00
2022-02-23 15:22:00 +03:00
An **unofficial** ebuild is available in [GURU ](https://github.com/gentoo/guru )
2022-04-02 18:52:35 +03:00
```zsh
2022-02-23 15:22:00 +03:00
eselect repository enable guru
emaint sync -r guru
emerge --ask gui-apps/swaync
```
2022-12-17 17:17:57 +03:00
### OpenSUSE Tumbleweed
```zsh
sudo zypper install SwayNotificationCenter
```
2023-05-11 22:53:41 +03:00
### Ubuntu
2022-12-17 17:12:31 +03:00
2023-06-14 13:34:59 +03:00
Lunar and later:
```
sudo apt install sway-notification-center
```
2022-12-17 17:12:31 +03:00
2023-05-11 22:53:41 +03:00
### Debian
2022-12-17 17:12:31 +03:00
2023-06-14 13:34:59 +03:00
Bookworm and later:
```
sudo apt install sway-notification-center
```
2022-12-17 17:12:31 +03:00
2023-08-14 21:27:15 +03:00
### Guix
The simplest way is to install it to user's profile:
```
guix install swaynotificationcenter
```
But we recommend to use [Guix Home ](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html ) to manage packages and their configurations declaratively.
### rde
```
(use-modules (rde features wm))
;; Include the following code into the list of your rde features:
(feature-swaynotificationcenter)
```
2023-05-11 22:53:41 +03:00
### Other
2021-07-30 23:36:50 +03:00
2023-12-20 21:31:39 +03:00
#### Dependencies
- `vala >= 0.56`
- `meson`
- `git`
- `scdoc`
- `sassc`
- `gtk3`
- `gtk-layer-shell`
- `dbus`
- `glib2`
- `gobject-introspection`
- `libgee`
- `json-glib`
- `libhandy`
- `gvfs`
- `granite`
##### Optional Dependencies
- `libpulse` (requires meson build options change)
- `libnotify`
2021-07-28 20:32:43 +03:00
```zsh
2023-12-20 21:31:39 +03:00
meson build --prefix=/usr
2021-07-28 20:32:43 +03:00
ninja -C build
2021-07-30 23:14:17 +03:00
meson install -C build
2021-07-28 20:32:43 +03:00
```
2021-09-16 11:43:53 +03:00
## Sway Usage
```ini
# Notification Daemon
exec swaync
2021-12-25 00:06:12 +03:00
# Toggle control center
2021-09-16 11:43:53 +03:00
bindsym $mod+Shift+n exec swaync-client -t -sw
```
2021-07-28 20:32:43 +03:00
## Run
2021-07-29 12:16:01 +03:00
To start the daemon (remember to kill any other notification daemon before running)
2021-07-28 20:32:43 +03:00
```zsh
2021-07-30 19:59:06 +03:00
./build/src/swaync
2021-07-28 20:32:43 +03:00
```
To toggle the panel
```zsh
2021-07-31 01:37:11 +03:00
./build/src/swaync-client -t
2021-07-28 20:32:43 +03:00
```
2021-10-13 14:19:38 +03:00
To reload the config
```zsh
./build/src/swaync-client -R
```
2022-02-09 01:52:14 +03:00
To reload css after changes
```zsh
./build/src/swaync-client -rs
```
2021-12-25 00:06:12 +03:00
## Control Center Shortcuts
2021-08-02 19:39:53 +03:00
- Up/Down: Navigate notifications
2021-08-02 20:03:18 +03:00
- Home: Navigate to the latest notification
- End: Navigate to the oldest notification
2021-08-02 19:39:53 +03:00
- Escape/Caps_Lock: Close notification panel
- Return: Execute default action or close notification if none
- Delete/BackSpace: Close notification
2022-01-21 13:45:27 +03:00
- Shift+C: Close all notifications
- Shift+D: Toggle Do Not Disturb
2021-08-02 19:39:53 +03:00
- Buttons 1-9: Execute alternative actions
2022-04-05 18:19:14 +03:00
- Left click button / actions: Activate notification action
- Right click notification: Close notification
2021-08-02 19:39:53 +03:00
2021-07-31 01:37:11 +03:00
## Configuring
2021-10-16 19:43:25 +03:00
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.
2022-12-23 17:44:26 +03:00
See `swaync(5)` man page for more information
2021-08-06 21:00:44 +03:00
2021-10-13 14:19:38 +03:00
To reload the config, you'll need to run `swaync-client --reload-config`
2023-12-14 19:12:30 +03:00
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. For
more advanced/larger themes, I recommend that you use the SCSS files from source
and customize them instead. To use the SCSS files, compile with `sassc` .
2023-05-07 21:00:19 +03:00
2023-12-14 19:12:30 +03:00
**Tip**: running swaync with `GTK_DEBUG=interactive swaync` will open a inspector
2023-05-07 21:00:19 +03:00
window that'll allow you to see all of the CSS classes + other information.
2021-07-31 01:37:11 +03:00
2023-11-13 02:52:26 +03:00
## Toggle Buttons
To add toggle buttons to your control center you can set the "type" in any acton to "toggle".
The toggle button supports different commands depending on the state of the button and
2023-11-28 08:50:26 +03:00
an "update-command" to update the state in case of changes from outside swaync. The update-command
is called every time the control center is opened.
2023-11-13 02:52:26 +03:00
The active toggle button also gains the css-class ".toggle:checked"
`config.json` example:
```json
{
2023-11-28 08:38:29 +03:00
"buttons-grid": { // also works with actions in menubar widget
2023-11-13 02:52:26 +03:00
"actions": [
{
"label": "WiFi",
"type": "toggle",
"active": true,
"command": "sh -c '[[ $SWAYNC_TOGGLE_STATE == true ]] & & nmcli radio wifi on || nmcli radio wifi off'",
2023-11-28 08:50:26 +03:00
"update-command": "sh -c '[[ $(nmcli radio wifi) == \"enabled\" ]] && echo true || echo false'"
2023-11-13 02:52:26 +03:00
}
]
}
}
```
2023-02-24 21:07:18 +03:00
## 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`
```conf
# 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"
```
2022-02-06 22:17:13 +03:00
## Scripting
Scripting rules and logic:
2022-04-02 18:52:35 +03:00
. < b > Only one< / b > 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
2022-12-13 14:14:11 +03:00
. If any of the properties doesn't match, the script will be skipped
2022-04-02 18:52:35 +03:00
. If a notification doesn't include one of the properties, that property will
2022-02-06 22:17:13 +03:00
be skipped
2023-01-03 20:56:59 +03:00
· If a script has `run-on` set to `action` , the script will only run when an
action is taken on the notification
2022-02-06 22:17:13 +03:00
2022-04-02 18:52:35 +03:00
More information can be found in the `swaync(5)` man page
2022-02-06 22:17:13 +03:00
Notification information can be printed into a terminal by running
`G_MESSAGES_DEBUG=all swaync` (when a notification appears).
Config properties:
```json
{
"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:
```json
{
"scripts": {
// This script will only run when Spotify sends a notification containing
// that exact summary and body
"example-script": {
2023-01-01 19:49:53 +03:00
"exec": "/path/to/myRickRollScript.sh",
2022-02-06 22:17:13 +03:00
"app-name": "Spotify"
"summary": "Never Gonna Give You Up",
"body": "Rick Astley - Whenever You Need Somebody"
}
}
other non scripting properties...
}
```
2022-02-07 18:55:48 +03:00
### Disable scripting
To completely disable scripting, the project needs to be built like so:
```zsh
meson build -Dscripting=false
ninja -C build
meson install -C build
```
2023-01-19 21:46:52 +03:00
## i3status-rs Example
2023-06-14 18:38:41 +03:00
> **Note** Ths requires i3status-rs version 0.31.0+
2023-01-19 21:46:52 +03:00
i3status-rs config
```toml
[[block]]
block = "notify"
2023-06-14 18:38:41 +03:00
format = " $icon {($notification_count.eng(w:1)) |}"
2023-01-19 21:46:52 +03:00
driver = "swaync"
[[block.click]]
button = "left"
action = "show"
[[block.click]]
button = "right"
action = "toggle_paused"
```
2022-01-11 03:05:44 +03:00
## Waybar Example
This example requires `NotoSansMono Nerd Font` to get the icons looking right
Waybar config
```json
"custom/notification": {
"tooltip": false,
"format": "{icon}",
"format-icons": {
"notification": "< span foreground = 'red' > < sup > < / sup > < / span > ",
"none": "",
"dnd-notification": "< span foreground = 'red' > < sup > < / sup > < / span > ",
2023-02-23 23:41:08 +03:00
"dnd-none": "",
"inhibited-notification": "< span foreground = 'red' > < sup > < / sup > < / span > ",
"inhibited-none": "",
"dnd-inhibited-notification": "< span foreground = 'red' > < sup > < / sup > < / span > ",
"dnd-inhibited-none": ""
2022-01-11 03:05:44 +03:00
},
"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
```css
#custom-notification {
font-family: "NotoSansMono Nerd Font";
}
```
2022-07-10 12:40:19 +03:00
Alternatively, the number of notifications can be shown by adding `{}` anywhere in the `format` field in the Waybar config
```json
"custom/notification": {
"format": "{} {icon}",
...
},
```