Skip to content

Commit

Permalink
Fix: Initialization and Error Handling for Libnotify (#2659)
Browse files Browse the repository at this point in the history
* fix libnotify
* Add notification error handling
  • Loading branch information
JC-comp authored Mar 10, 2024
1 parent fda0430 commit 3d249b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/log.d
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ class LogBuffer {
shared void notify(string message) {
// Use dnotify's functionality for GUI notifications, if GUI notifications is enabled
version(Notifications) {
auto n = new Notification("Log Notification", message, "IGNORED");
n.show();
try {
auto n = new Notification("Log Notification", message, "IGNORED");
n.show();
} catch (NotificationError e) {
sendGUINotification = false;
addLogEntry("Unable to send notification; disabled in the following: " ~ e.message);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/notifications/dnotify.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ void init(in char[] name) {
alias notify_is_initted is_initted;
alias notify_uninit uninit;

static this() {
shared static this() {
init(__FILE__);
}

static ~this() {
shared static ~this() {
uninit();
}

Expand Down

0 comments on commit 3d249b8

Please sign in to comment.