I’ve double checked that I can create a Vala app that can create pop-up notifications (see example Notify.Notification – libnotify).
Using a more recently written Go library (golibnotify
) instead of the antique go-notify
(which came recommended in the Arch Wiki), I was also able to create pop-up notifications that appear consistently. That must mean notify-send
is broken on PureOS/Wayland/ARM/… in some way.
I still do not get a notification sound, which is the next step. I would be sad if I would have to play a sound myself.
Edit
(Apparently, you can’t reply to a post more than 3 times without somebody else also replying in between. So that’s why an edit.)
Flare creates pop-up notifications using feedbackd
. feedbackd
was written by Purism as a way “to provide haptic, visual and audio feedback”. Even better than what I looked for.
Working example:
- First
apt install libfeedback-dev libnotify-dev
.
- Create a simple application in file
notify.vala
(that skips error checking for simplicity):
public static int main(string[] args) {
string summary = "The title";
string body = "A long description";
string icon = "dialog-information";
Notify.init("My test app");
new Notify.Notification(summary, body, icon).show();
Lfb.init("My test app");
var event = new Lfb.Event("message-new-sms");
event.trigger_feedback();
GLib.Thread.usleep(2000000);
return 0;
}
Build with:
$ valac -C --pkg libfeedback-0.0 --pkg libnotify notify.vala
$ sed -i '0,/^$/s//#define LIBFEEDBACK_USE_UNSTABLE_API/' notify.c
$ valac --pkg libfeedback-0.0 --pkg libnotify notify.c
$ ./notify
As you can see, we cannot build the final executable with a single invocation. That is because libfeedback
requires to set the LIBFEEDBACK_USE_UNSTABLE_API
macro. vala
does not allow to set #define MACRO
macros in source code directly, so we have to resort to a 2-stage build. Sigh.
The Thread#usleep
is necessary to keep the app alive long enough so it won’t prematurely disconnect from DBus. feedbackd
stops the feedback when that happens, resulting in no feedback noticeable at all.
Anyway. On my L5, this shows both a pop-up notification and plays the “SMS received” sound.
Next step is to create a Go library that delegates to this libfeedback
C library, so I can finally create a pop-up notification with sound in Go as well.
(Also, I found this thread on these forums that talk about not being able to get sound with a notification. So for reference.)