2021-07-28 20:32:43 +03:00
# SwayNotificationCenter
2022-04-02 18:52:35 +03:00
[![Building ](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/building.yml/badge.svg )](https://github.com/ErikReider/SwayNotificationCenter/actions/workflows/building.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
## Features
2021-08-02 19:39:53 +03:00
- Keyboard shortcuts
2021-08-07 16:44:32 +03:00
- Notification body markup with image support
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
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
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`
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
2021-07-30 23:36:50 +03:00
Arch:
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
2022-01-16 20:47:45 +03:00
Fedora:
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
```
2022-02-23 15:22:00 +03:00
Gentoo:
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
```
2021-07-30 23:36:50 +03:00
Other:
2021-07-28 20:32:43 +03:00
```zsh
meson build
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-04-02 18:52:35 +03:00
See `swaync(1)` 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`
2022-04-02 18:52:35 +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.
2021-07-31 01:37:11 +03:00
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
. If any of the propeties doesn't match, the script will be skipped
. If a notification doesn't include one of the properties, that property will
2022-02-06 22:17:13 +03:00
be skipped
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": {
"exec": "~/.config/swaync/myRickRollScript.sh",
"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
```
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 > ",
"dnd-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
```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}",
...
},
```
2021-07-29 00:14:38 +03:00
## Screenshots
![Screenshot of desktop notification ](./assets/desktop.png )
![Screenshot of panel ](./assets/panel.png )
2021-08-01 01:23:34 +03:00
I wonder how this would look with some blur 🤔