Code Monkey home page Code Monkey logo

swaynotificationcenter's Introduction

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

Demo

demo.mp4

Screenshot of panel

Table of Contents

Want to show off your sick config?

Post your setup here: Config flex 💪

Features

  • Grouped notifications
  • 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

Alpine Linux

apk add swaync

Arch

sudo pacman -S swaync

Alternatively, swaync-git 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:

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 
rpm-ostree install SwayNotificationCenter

Gentoo

An unofficial ebuild is available in GURU

eselect repository enable guru
emaint sync --repo 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

Guix

The simplest way is to install it to user's profile:

guix install swaynotificationcenter

But we recommend to use Guix Home 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)

Other

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
meson setup build --prefix=/usr
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
  • Middle/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. 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.

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.

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 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. The active toggle button also gains the css-class ".toggle:checked"

config.json example:

{
  "buttons-grid": { // also works with actions in menubar widget
    "actions": [
      {
        "label": "WiFi",
        "type": "toggle",
        "active": true,
        "command": "sh -c '[[ $SWAYNC_TOGGLE_STATE == true ]] && nmcli radio wifi on || nmcli radio wifi off'",
        "update-command": "sh -c '[[ $(nmcli radio wifi) == \"enabled\" ]] && echo true || echo false'"
      }
    ]
  }
}

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}",
    // ...
  },

swaynotificationcenter's People

Contributors

1over137 avatar abcdw avatar abmantis avatar aereaux avatar apostroll avatar aruhier avatar berbiche avatar bim9262 avatar boh132boh avatar bvergnaud avatar capezotte avatar carlosv2 avatar christopher-l avatar cyrinux avatar dev-dev-dev-dev-dev-dev-dev-dev avatar erikreider avatar fantognazza avatar foopsss avatar freijon avatar jannispetschenka avatar kilobyte avatar lawngnome avatar lexa avatar neon64 avatar nightly-brew avatar o0nd7ots avatar scarwire avatar seme4eg avatar system64fumo avatar tosti007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

swaynotificationcenter's Issues

Trigger reload of style.css

I just tried swaync and I quite like it so far.

However I have one question / request:
I use flavours (https://github.com/Misterio77/flavours/) to inject base16 color schemes in the style.css of swaync which works fine. However, in order for the changed colors to be applied, I have to kill and restart swaync.

Would it be possible to live-reload style.css, like it can be done with swaync-client -R for the config file?

Thanks for your effort!

Customisable Notification timeout

Hi,

Thanks for your awesome tools, I really like the design and ease of use of this tool. However, I would like to customise timeout length of a popping notification, is there a way to do so in config file?

Investigate support for xdg activation token

Was browsing freedesktop gitlab instance and I read about xdg activation protocol.
On wayland.app it says it's still staging as a protocol, but in the future this should allow clicking on a notification and automatically focusing the sender's surface on wayland, with specific protections about focus stealing.
(Of course, the compositor needs to support that).

I'm almost sure close to no applications provide said token, nor it's currently standardised, still it would be really good to have.

Fails to show with libhandy 1.2

Regressed by 37b6e3d due to missing GNOME/libhandy@47bad070c5e4. Works fine with libhandy 1.4. Maybe bump minimal version in

dependency('libhandy-1', version: '>= 1.0.0'),

$ pkg info -x handy layer-shell json-glib
libhandy-1.2.3
gtk-layer-shell-0.6.0_1
json-glib-1.6.2_1

$ swaync &
$ notify-send "this is the summary" "this is the body"
(swaync:1234): Gtk-CRITICAL **: Error building template class 'SwayNotificatonCenterNotification' for an instance of type 'SwayNotificatonCenterNotification': .:14:46 Invalid property: HdyCarousel.allow-scroll-wheel
(swaync:1234): Gtk-CRITICAL **: gtk_label_set_text: assertion 'GTK_IS_LABEL (label)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): Handy-CRITICAL **: hdy_carousel_scroll_to: assertion 'HDY_IS_CAROUSEL (self)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_label_set_markup: assertion 'GTK_IS_LABEL (label)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_image_set_pixel_size: assertion 'GTK_IS_IMAGE (image)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_image_set_from_icon_name: assertion 'GTK_IS_IMAGE (image)' failed
(swaync:1234): Gtk-CRITICAL **: Error building template class 'SwayNotificatonCenterNotification' for an instance of type 'SwayNotificatonCenterNotification': .:14:46 Invalid property: HdyCarousel.allow-scroll-wheel
(swaync:1234): Gtk-CRITICAL **: gtk_label_set_text: assertion 'GTK_IS_LABEL (label)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): Handy-CRITICAL **: hdy_carousel_scroll_to: assertion 'HDY_IS_CAROUSEL (self)' failed
(swaync:1234): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(swaync:1234): GLib-GObject-CRITICAL **: g_signal_connect_object: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_label_set_markup: assertion 'GTK_IS_LABEL (label)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_image_set_pixel_size: assertion 'GTK_IS_IMAGE (image)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_image_set_from_icon_name: assertion 'GTK_IS_IMAGE (image)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_label_set_lines: assertion 'GTK_IS_LABEL (label)' failed
(swaync:1234): Gtk-CRITICAL **: gtk_label_set_text: assertion 'GTK_IS_LABEL (label)' failed

Light theme issue

nice work, this looks quite usable even in begining

It looks as it should per your screenshots, while using a dark gtk theme. while using WhiteSur-light gtk theme, it looks like this.
image

also looks quite sizable in my 1080p laptop, hope it will be configurable later on

Improve accessibiity

Although swaync is already a great program, both in configurability and usability, I think it needs a little bit of improvement when it comes to accessibility.

I admit I haven't dug into the code to see if it works good with any screen reader or something like that, nor I have tried setting one up as I don't need them, but I think it could help a lot of people with visual impairments.
My apologies if it's already "compliant" and I haven't noticed.

I don't know how much work it's needed, nor I'm fluent in Vala, but I could try to help somewhat when I get a hang of the language.

edit: my apologies, swaync is already navigable with the keyboard, but through shortcuts. I was trying to toggle the dnd button by getting to it with the arrow keys. Lovely that it already works!

Enable dbus activation for swaync

Hi, I suspect swaync does not register itself as dbus-activable and I think it would be good if it was the case instead.
This should help avoid missing notifications in case no service is started: if dbus gets a "message" for org.freedesktop.Notifications it should be able to start swaync automatically.

This could also explain why in #32 mako was running on top of swaync, it must have been started by dbus (even though swaync should have been bound to org.freedesktop.Notifications so it shouldn't have happened, but my knowledge on the inner workings of dbus is little to zero so I may be wrong).

Do you think it could be a useful change?

Fix vala namespace typo

The namespace around the program is "SwayNotificatonCenter", it lacks an 'i'.

(Just a reminder for myself to fix it)

Comments in JSON cause warnings on running

Looks like comments aren't valid JSON, and at least on my system cause errors when loading.
Testing JSON is valid using jq fails with the comments in there.
Stripping out the comments gets rid of the error.
Using stock config file from arch AUR

❯ swaync
/etc/xdg/swaync/config.json:1:1: Parse error: unexpected character `{', expected string constant
^C
❯ jq < /etc/xdg/swaync/config.json
parse error: Invalid numeric literal at line 2, column 5
❯ cat /etc/xdg/swaync/config.json
{
  // X-axis position
  "positionX": "right",
  // Y-axis position
  "positionY": "top",
  // Timeout for normal priority notifications
  "timeout": 10,
  // Timeout for low priority notifications
  "timeout-low": 5,
  // If control center should use keyboard shortcuts
  "keyboard_shortcuts": true,
  // Sets the notification image visiblilty
  "image-visibility": "always"
}
❯ sudo sed -i 's#//.*##' /etc/xdg/swaync/config.json
❯ swaync
^C
❯ 
❯ jq < /etc/xdg/swaync/config.json
{
  "positionX": "right",
  "positionY": "top",
  "timeout": 10,
  "timeout-low": 5,
  "keyboard_shortcuts": true,
  "image-visibility": "always"
}
❯ cat /etc/xdg/swaync/config.json
{
  
  "positionX": "right",
  
  "positionY": "top",
  
  "timeout": 10,
  
  "timeout-low": 5,
  
  "keyboard_shortcuts": true,
  
  "image-visibility": "always"
}

Action icons

The notifier should be able to set icons per action

Consume keyboard events

If you want my advice: keyboard support should "consume" events (return true), in order not to trigger them on other windows. E.g. if I open Azote, which closes on Esc, then the notification center, and then press Escape, both windows will be closed. Same applies to the CapsLock key, I suppose, though I'm not sure if it's gonna work. I'd expect it to just close the notification panel, w/o switching the CapsLock state.

XML-encoded characters are not "unescaped"

Some applications send notifications containing XML-encoded entities.
These characters are not replaced when showing the notification.

SwayNotificationCenter:
image

Mako:
image

Dunst:
image

Tested with notify-send allo "c&#39;est révolutionnaire".

Systemd unit file

Would it be possible to have swaync shipped by default with a systemd unit file?
I wrote a simple one based on the file that comes with mako, if it may help.

[Unit]
Description=Swaync notification daemon
Documentation=https://github.com/ErikReider/SwayNotificationCenter
PartOf=graphical-session.target
After=graphical-session.target
Requisite=graphical-session.target
# ConditionEnvironment requires systemd v247 to work correctly
ConditionEnvironment=WAYLAND_DISPLAY

[Service]
Type=dbus
BusName=org.freedesktop.Notifications
ExecStart=/usr/bin/swaync
ExecReload=/usr/bin/swaync-client --reload-config --reload-css
Restart=on-failure

[Install]
WantedBy=graphical-session.target

Provide notify-send

One way to easily catch all notifications on a system would be to create a link from /usr/bin/notify-send => /usr/bin/swaync-client. Calls to notify-send – the de-facto standard for everything notification-related – could be detected by checking argv[0] and then provide the usual CLI: https://man.archlinux.org/man/notify-send.1

This would also allow to easily send notifications to SwayNC from scripts.

GitHub building Actions

GitHub Actions that build the project on different distros like Arch, Fedora, Ubuntu, etc...

[Feature Request] Ability to hide/display DND widget

I believe that you could simply wrap these lines in a conditional to accomplish this (as an init config item):

dnd_button = new Gtk.Switch ();
dnd_button.get_style_context ().add_class ("control-center-dnd");
dnd_button.state_set.connect ((widget, state) => {
try {
cc_daemon.set_dnd (state);
} catch (Error e) {
stderr.printf (e.message + "\n");
}
return false;
});
this.box.add (new TopAction ("Do Not Disturb", dnd_button, false));
}

style.css fails with non-default prefix

18a7dee defined sysconfdir but forgot to replace /etc and propagate it to C consumer.

$ meson setup --prefix=/tmp/test /tmp/swaync_build
$ meson install -C /tmp/swaync_build
Installing src/swaync to /tmp/test/bin
Installing src/swaync-client to /tmp/test/bin
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 227, in run
    return options.run_func(options)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 720, in run
    installer.do_install(datafilename)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 515, in do_install
    self.install_data(d, dm, destdir, fullprefix)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 549, in install_data
    if self.do_copyfile(fullfilename, outfilename, makedirs=(dm, outdir)):
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 400, in do_copyfile
    dirmaker.makedirs(outdir, exist_ok=True)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 102, in makedirs
    self.makedirs_impl(path, exist_ok=exist_ok)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 306, in makedirs
    os.makedirs(*args, **kwargs)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/etc/xdg'
$ cd /tmp # or anywhere else outside of swaync source
$ /tmp/test/bin/swaync
COULD NOT FIND CSS FILE! REINSTALL THE PACKAGE!

Scripting supported

Hey there,

With dunst Im able to script actions for specific notifications.

Is this possible with SwayNotificationsCenter?

Print DND Status

I know this is small, but I want an option to only print the DND status and not change it. I could always make a script that changes it first, then checks its status when it is changed back, but that is just janky. Here is a patch I made based on the most recent commit.

--- a/src/client.vala
+++ b/src/client.vala
@@ -27,6 +27,7 @@ private void print_help (string[] args) {
     print (@"\t -R, --reload-config \t Reload the config file\n");
     print (@"\t -t, --toggle-panel \t Toggle the notificaion panel\n");
     print (@"\t -d, --toggle-dnd \t Toggle and print the current dnd state\n");
+    print (@"\t -D, --get-dnd \t Print the current dnd state\n");
     print (@"\t -c, --count \t\t Print the current notificaion count\n");
     print (@"\t -C, --close-all \t Closes all notifications\n");
     print (@"\t -sw, --skip-wait \t Doesn't wait when swaync hasn't been started\n");
@@ -71,6 +72,10 @@ public int command_line (string[] args) {
             case "-d":
                 print (cc_daemon.toggle_dnd ().to_string ());
                 break;
+	   case "--get-dnd":
+	   case "-D":
+		print(cc_daemon.get_dnd ().to_string ());
+		break;
             case "--subscribe":
             case "-s":
                 cc_daemon.subscribe.connect ((c, d) => on_subscribe (c, d));

I tried to make a PR but I couldn't figure out how lol. Please add this functionality in, I have tested this and it works :).

To use this patch just copy and save to a file, say "mypatch.patch". And then in main project folder just git apply mypatch.patch.

Can't run

When i try to run ./build/src/sway-nc i have this message: Could not aquire notification name
OS: Arch
WM: Sway

try using releases for swaync

it would be better if swaync would be released as versions as its not fun to make it and restart swaync after every commit...
and make the AUR package use the release and not -git

Build error

Ubuntu 21.04
libjson-glib-dev/hirsute,now 1.6.2-1 amd64
libgtk-layer-shell-dev/hirsute 0.5.2-1 amd64

The Meson build system
Version: 0.59.1
Source dir: /home/luke/code/wayland/SwayNotificationCenter
Build dir: /home/luke/code/wayland/SwayNotificationCenter/build
Build type: native build
Project name: sway-notificaton-center
Project version: 0.1.0
C compiler for the host machine: cc (gcc 10.3.0 "cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0")
C linker for the host machine: cc ld.bfd 2.36.1
Vala compiler for the host machine: valac (valac 0.48.17)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency gio-2.0 found: YES 2.68.1
Run-time dependency gtk+-3.0 found: YES 3.24.25
Run-time dependency json-glib-1.0 found: YES 1.6.2
Library gtk-layer-shell found: YES
Library m found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Program glib-compile-resources found: YES (/usr/bin/glib-compile-resources)
Build targets in project: 4

Found ninja-1.10.1 at /usr/bin/ninja
-:~/code/wayland/SwayNotificationCenter$ ninja -C build/
ninja: Entering directory `build/'
[5/18] Compiling Vala source ../src/main.vala ../src/notiDaemon/n...Action/topAction.vala ../src/constants.vala ../src/functions.vala
FAILED: src/swaync.p/main.c src/swaync.p/notiDaemon/notiDaemon.c src/swaync.p/configModel/configModel.c src/swaync.p/notiWindow/notiWindow.c src/swaync.p/notification/notification.c src/swaync.p/controlCenter/controlCenter.c src/swaync.p/controlCenter/topAction/topAction.c src/swaync.p/constants.c src/swaync.p/functions.c 
valac -C --debug --debug --pkg json-glib-1.0 --pkg gtk+-3.0 --pkg gio-2.0 --color=always --directory src/swaync.p --basedir ../src --gresources=../src/sway_notificaton_center.gresource.xml --target-glib=2.50 --pkg=GtkLayerShell-0.1 ../src/main.vala ../src/notiDaemon/notiDaemon.vala ../src/configModel/configModel.vala ../src/notiWindow/notiWindow.vala ../src/notification/notification.vala ../src/controlCenter/controlCenter.vala ../src/controlCenter/topAction/topAction.vala ../src/constants.vala ../src/functions.vala
../src/controlCenter/controlCenter.vala:97.13-97.43: error: The name `set_keyboard_mode' does not exist in the context of `GtkLayerShell' (gtk-layer-shell-0)
            GtkLayerShell.set_keyboard_mode (this, GtkLayerShell.KeyboardMode.ON_DEMAND);
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
[7/18] Compiling C object src/swaync-client.p/meson-generated_client.c.o
ninja: build stopped: subcommand failed.

Potentially related to wmww/gtk-layer-shell@9cd93e9
Perhaps there should be a minimum version defined for gtk-layer-shell of 0.6.0 to cover this?

Change default image or default visibility

The default behaviour states that a notification always comes with a visible image, and it resorts at last to a broken_image icon when it was not possible to gather an image, app icon or desktop icon from the provided info.

The implementation works flawlessly for what I could try, but it also makes the noti history look quite strange this way, especially if one has multiple scripts sending messages to the user without icons or images.
It kinda feel broken.

Wouldn't it be better to change the default visibility to "when-available" or change the fallback image to something more generic and less broken-looking?

Play sounds for new notifications

Some notification daemons support playing sounds when a new notification pops up, some don't.
The xdg notification spec even describes hints for controlling the sound behaviour, such as suppress, specify an xdg-sound-name to play or directly pass the path of a file.

AUR package build fails.

Build for both swaync and swaync-git packages fails with errors:

Arch Linux, vala-0.54.6

ninja: Entering directory `build'                                                                   
[4/20] Compiling Vala source ../SwayNotificationCenter-0.3/src/client.vala ../SwayNotificationCenter-0.3/src/constants.vala
FAILED: src/swaync-client.p/client.c src/swaync-client.p/constants.c 
valac -C -D HAVE_LATEST_GTK_LAYER_SHELL --pkg libhandy-1 --pkg json-glib-1.0 --pkg gtk+-3.0 --pkg gio-2.0 --color=always --directory src/swaync-client.p --basedir ../SwayNotificationCenter-0.3/src --target-glib=2.50 --pkg=GtkLayerShell-0.1 ../SwayNotificationCenter-0.3/src/client.vala ../SwayNotificationCenter-0.3/src/constants.vala

(valac:27699): vala-CRITICAL **: 17:35:46.656: string_substring: assertion '(offset + len) <= string_length' failed

(valac:27699): GLib-CRITICAL **: 17:35:46.656: g_string_insert_len: assertion 'len == 0 || val != NULL' failed
Atk-1.0.gir:2.15-2.48: error: expected start element of `repository'
Atk-1.0.gir:2.15-2.48: error: unsupported GIR version (null) (supported: 1.2)
Compilation failed: 2 error(s), 0 warning(s)
[5/20] Compiling Vala source ../SwayNotificationCenter-0.3/src/main.vala ....er-0.3/src/constants.vala ../SwayNotificationCenter-0.3/src/functions.vala
FAILED: src/swaync.p/main.c src/swaync.p/configModel/configModel.c src/swaync.p/notiDaemon/notiDaemon.c src/swaync.p/notiModel/notiModel.c src/swaync.p/notiWindow/notiWindow.c src/swaync.p/notification/notification.c src/swaync.p/ccDaemon/ccDaemon.c src/swaync.p/controlCenter/controlCenter.c src/swaync.p/controlCenter/topAction/topAction.c src/swaync.p/constants.c src/swaync.p/functions.c 
valac -C -D HAVE_LATEST_GTK_LAYER_SHELL --pkg libhandy-1 --pkg json-glib-1.0 --pkg gtk+-3.0 --pkg gio-2.0 --color=always --directory src/swaync.p --basedir ../SwayNotificationCenter-0.3/src --gresources=../SwayNotificationCenter-0.3/src/sway_notificaton_center.gresource.xml --target-glib=2.50 --pkg=GtkLayerShell-0.1 ../SwayNotificationCenter-0.3/src/main.vala ../SwayNotificationCenter-0.3/src/configModel/configModel.vala ../SwayNotificationCenter-0.3/src/notiDaemon/notiDaemon.vala ../SwayNotificationCenter-0.3/src/notiModel/notiModel.vala ../SwayNotificationCenter-0.3/src/notiWindow/notiWindow.vala ../SwayNotificationCenter-0.3/src/notification/notification.vala ../SwayNotificationCenter-0.3/src/ccDaemon/ccDaemon.vala ../SwayNotificationCenter-0.3/src/controlCenter/controlCenter.vala ../SwayNotificationCenter-0.3/src/controlCenter/topAction/topAction.vala ../SwayNotificationCenter-0.3/src/constants.vala ../SwayNotificationCenter-0.3/src/functions.vala

(valac:27698): vala-CRITICAL **: 17:35:46.656: string_substring: assertion '(offset + len) <= string_length' failed

(valac:27698): GLib-CRITICAL **: 17:35:46.656: g_string_insert_len: assertion 'len == 0 || val != NULL' failed
Atk-1.0.gir:2.15-2.48: error: expected start element of `repository'
Atk-1.0.gir:2.15-2.48: error: unsupported GIR version (null) (supported: 1.2)
Compilation failed: 2 error(s), 0 warning(s)
ninja: build stopped: subcommand failed.

Clear all notifications doesn't trigger default nor close actions for notifications

I was playing with notify-send.py, creating notifications with buttons, for the sake of testing orca.

notify-send.py is different from the classic notify-send, as it waits for the notification to either expire, be closed or be acted upon (if it has action buttons, of course), otherwise the script remains waiting for a status change from the notification.

Well, if I click the notification manually or with keyboard it correctly triggers the default action. If I close it, it registers as so.
Even button actions seem to work as intended.

The clear all button in the control center though, it doesn't seem to send a close action to the programs (nor a default, which one is better suited is up to discussion as far as I kow), so things like bluetooth-manager or notify-send.py wait idly for something to happen, but on the swaync side the notification isn't there anymore.

Replacing a notification closes it

I just updated to the latest commit, and I noticed mpDris2 notification was cancelling itself whenever it updated.

I verified with the help of notify-send.py and notify-send.sh and I can affirm that for some reason, updating a notification triggers its close action.

Steps to reproduce:

  1. Send a notification with notify-send.sh, setting the default action and the close action to print two different strings, and making the command print the notification id.
notify-send.sh "replace me" --print-id --default-action "echo default" --close-action "echo closed"
  1. Replace the notification by using its id (I used notify-send.py, but notify-send.sh can also do this). Let's say the notification gets id 28.
notify-send.py -r 28 "I was replaced"

At this point, the original one is replaced then quickly closed.

style.css is requested at runtime but not installed

$ git describe --tags --always
6421ec2
$ meson setup _build
$ meson install -C _build
$ cd /tmp
$ sway-nc
Error: <broken file>:1:0Failed to import: Error opening file /tmp/src/style.css: No such file or directory
^C

Unmet dependencies

Could you list the needed dependencies more explicitly?

The AUR package fails to build for me.

$ yay -S swaync-git
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur:1]  swaync-git-0.1.r70.f344600-1

  1 swaync-git                       (Build Files Exist)
==> Packages to cleanBuild?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==>
:: PKGBUILD up to date, Skipping (1/1): swaync-git
  1 swaync-git                       (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==>
:: (1/1) Parsing SRCINFO: swaync-git
==> Making package: swaync-git 0.1.r70.f344600-1 (Sat 31 Jul 2021 03:30:35 PM CEST)
==> Retrieving sources...
  -> Updating SwayNotificationCenter git repo...
Fetching origin
==> Validating source files with sha256sums...
    SwayNotificationCenter ... Skipped
==> Making package: swaync-git 0.1.r70.f344600-1 (Sat 31 Jul 2021 03:30:37 PM CEST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating SwayNotificationCenter git repo...
Fetching origin
==> Validating source files with sha256sums...
    SwayNotificationCenter ... Skipped
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Creating working copy of SwayNotificationCenter git repo...
Cloning into 'SwayNotificationCenter'...
done.
==> Starting pkgver()...
==> Updated version: swaync-git 0.1.r76.de55a18-1
==> Sources are ready.
==> Making package: swaync-git 0.1.r76.de55a18-1 (Sat 31 Jul 2021 03:30:39 PM CEST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
+ exec meson setup --prefix /usr --libexecdir lib --sbindir bin --buildtype plain --auto-features enabled --wrap-mode nodownload -D b_lto=true -D b_pie=true SwayNotificationCenter build
The Meson build system
Version: 0.59.0
Source dir: /user/.cache/yay/swaync-git/src/SwayNotificationCenter
Build dir: /user/.cache/yay/swaync-git/src/build
Build type: native build
Project name: sway-notificaton-center
Project version: 0.1.0
C compiler for the host machine: cc (gcc 11.1.0 "cc (GCC) 11.1.0")
C linker for the host machine: cc ld.bfd 2.36.1
Vala compiler for the host machine: valac (valac 0.52.4)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.7.3)
Run-time dependency gio-2.0 found: YES 2.68.3
Run-time dependency gtk+-3.0 found: YES 3.24.30
Run-time dependency libhandy-1 found: YES 1.2.3
Library gtk-layer-shell found: YES
Library m found: YES
Found pkg-config: /usr/bin/pkg-config (1.7.3)
Program glib-compile-resources found: YES (/usr/bin/glib-compile-resources)
Build targets in project: 4

Found ninja-1.10.2 at /usr/bin/ninja
ninja: Entering directory `build'
[4/15] Compiling Vala source ../SwayNotificationCenter/src/client.vala ../SwayNotificationCenter/src/constants.vala
FAILED: src/swaync-client.p/client.c src/swaync-client.p/constants.c
valac -C --pkg libhandy-1 --pkg gtk+-3.0 --pkg gio-2.0 --color=always --directory src/swaync-client.p --basedir ../SwayNotificationCenter/src --target-glib=2.50 --pkg=GtkLayerShell-0.1 ../SwayNotificationCenter/src/client.vala ../SwayNotificationCenter/src/constants.vala
error: Package `xlib-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GObject-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `Gio-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `cairo-1.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GModule-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `Gio-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GObject-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `cairo-1.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GObject-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
Compilation failed: 9 error(s), 0 warning(s)
[5/15] Compiling Vala source ../SwayNotificationCenter/src/main.vala ../SwayNotificationCenter/src/notiWi...trolCenter.vala ../SwayNotificationCenter/src/constants.vala ../SwayNotificationCenter/src/functions.vala
FAILED: src/swaync.p/main.c src/swaync.p/notiWindow/notiWindow.c src/swaync.p/notification/notification.c src/swaync.p/controlCenter/controlCenter.c src/swaync.p/constants.c src/swaync.p/functions.c
valac -C --pkg libhandy-1 --pkg gtk+-3.0 --pkg gio-2.0 --color=always --directory src/swaync.p --basedir ../SwayNotificationCenter/src --gresources=../SwayNotificationCenter/src/sway_notificaton_center.gresource.xml --target-glib=2.50 --pkg=GtkLayerShell-0.1 ../SwayNotificationCenter/src/main.vala ../SwayNotificationCenter/src/notiWindow/notiWindow.vala ../SwayNotificationCenter/src/notification/notification.vala ../SwayNotificationCenter/src/controlCenter/controlCenter.vala ../SwayNotificationCenter/src/constants.vala ../SwayNotificationCenter/src/functions.vala
error: Package `xlib-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GObject-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `Gio-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `cairo-1.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GModule-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `Gio-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GObject-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `cairo-1.0' not found in specified Vala API directories or GObject-Introspection GIR directories
error: Package `GObject-2.0' not found in specified Vala API directories or GObject-Introspection GIR directories
Compilation failed: 9 error(s), 0 warning(s)
ninja: build stopped: subcommand failed.
==> ERROR: A failure occurred in build().
    Aborting...
error making: swaync-git

Add close and open functions to swaync-client

swaync-client --toggle-panel is great for toggling the center with a simple keybind, but from a scripting point of view it is not possible to force the control center in one of the two statuses directly though the client.

I'm envisioning something like
swaync-client --open-panel
swaync-client --close-panel

Unless the program itself doesn't have a feedback on the status of the panel, which I don't think is the case, this sounds relatively easy to implement.

I can try my hand at it tomorrow if you like the idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.