Skip to content

Commit

Permalink
ts: services: notifications: Add support for feedbackd
Browse files Browse the repository at this point in the history
  • Loading branch information
bellegarde-c committed Dec 7, 2024
1 parent 846d13d commit 019ca49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"config": "3.3.12",
"copy-text-to-clipboard": "2.1.0",
"dashdash": "2.0.0",
"dbus-next": "0.10.2",
"direction": "1.0.4",
"emoji-datasource": "15.1.2",
"emoji-datasource-apple": "15.1.2",
Expand Down Expand Up @@ -189,6 +190,7 @@
"uuid": "11.0.2",
"websocket": "1.0.34",
"write-file-atomic": "6.0.0",
"x11": "2.3.0",
"zod": "3.23.8"
},
"devDependencies": {
Expand Down
28 changes: 18 additions & 10 deletions ts/services/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ class NotificationService extends EventEmitter {
this.update();
}

private async feedback(): void {
try {
let dbus = require('dbus-next');
let bus = dbus.sessionBus();
let object = await bus.getProxyObject('org.sigxcpu.Feedback', '/org/sigxcpu/Feedback');
let iface = object.getInterface('org.sigxcpu.Feedback');
await iface.TriggerFeedback(
"signal-desktop",
"message-new-instant",
{},
-1
);
} catch(error) {
console.log(error);
}
}

/**
* A lower-level wrapper around `window.Notification`. You may prefer to use `add`,
* which includes debouncing and user permission logic.
Expand Down Expand Up @@ -226,15 +243,9 @@ class NotificationService extends EventEmitter {
}
};

this.feedback();
this.lastNotification = notification;
}

if (!silent) {
const soundType =
messageId && !useTriToneSound ? SoundType.Pop : SoundType.TriTone;
// We kick off the sound to be played. No need to await it.
drop(new Sound({ soundType }).play());
}
}

// Remove the last notification if both conditions hold:
Expand Down Expand Up @@ -325,9 +336,6 @@ class NotificationService extends EventEmitter {
notificationData ? '' : 'no '
}notification data`
);
if (isAppFocused) {
this.notificationData = null;
}
return;
}

Expand Down

0 comments on commit 019ca49

Please sign in to comment.