wnayes / bond-wm

An X Window Manager built on web technologies.
https://wnayes.github.io/bond-wm/
MIT License
67 stars 2 forks source link

Notification support? #5

Open danielmeloalencar opened 2 years ago

danielmeloalencar commented 2 years ago

Hello! Do you intend to add notification support?

wnayes commented 2 years ago

I prototyped a bit of the implementation of the System Tray Protocol Specification in 47dfad7f138ac485b22e75d1901147507ad1c372, but it seems like any app I tried is not actually using this protocol.

It may be that this specification is more commonly used.

danielmeloalencar commented 6 months ago

You must register bond-wm as a notification service with dbus. Alternatively, I was able to perform notification using xfce4-notifyd. But first it was necessary to run

sudo apt install dbus-x11

sudo apt-get install libnotify-cil-dev

sudo apt install xfce4-notifyd

sudo service dbus start

export $(dbus-launch) (this is very important)

notify-send "Hello"

Tested with ubuntu 22.04 xorg

danielmeloalencar commented 5 months ago

I prototyped a bit of the implementation of the System Tray Protocol Specification in 47dfad7, but it seems like any app I tried is not actually using this protocol.

It may be that this specification is more commonly used.

Maybe this can help:

const dbus = require('dbus-native');

// Connection to the D-Bus system message
const systemBus = dbus.systemBus();

if (!systemBus) {
    throw new Error('Could not connect to the DBus session bus.');
}

// Service name for the notify-daemon
const serviceName = 'org.freedesktop.Notifications';

// Object path for notifications
const objectPath = '/org/freedesktop/Notifications';

// Interface name for notifications
const interfaceName = 'org.freedesktop.Notifications';

// Getting a proxy to interact with the notifications service
const notifications = systemBus.getService(serviceName).getInterface(objectPath, interfaceName);

// Function to handle new notifications
function handleNotification(appName, summary, body) {
    console.log('New notification:');
    console.log('Application:', appName);
    console.log('Summary:', summary);
    console.log('Body:', body);
    console.log('---');
}

// Subscribe to receive notifications
notifications.on('Notification', handleNotification);

// Define the error handling function
notifications.on('error', function(err) {
    console.error('Error receiving notification:', err);
});

console.log('Waiting for notifications...');

// Keeps the process running
process.stdin.resume();
danielmeloalencar commented 2 weeks ago

I believe that now with ChildWindow used in the Start Menu it is better to implement the notification UI