Custom notes app registration

For my Notes Plus app I got a query from a user whether it’s possible to make the top menu “ Write a note” item call my app instead of Jolla Notes. From what I know it is currently not possible without a system patch.

Can we get a way to register a custom application for this? Maybe this could be solved with a URL handler?

If Jolla Notes would support let’s say notes://new and the OS would call this when touching “Write a note” in the top menu, the only thing that would be missing was a way to set the default application for notes.

Or is there a D-BUS variant of this?

1 Like

This is absolutely possible without any patching or other weird hacks.

However, because you have to install files under the Jolla Settings path, it won’t be harbour-compatible.
(What I would do in this case is package the non-harbour-allowed files in a separate rpm, and distribute that as an “Addon” through one of the other stores.

Let me look it up, and I shall describe how.

6 Likes

As a quick reference, this is how my app Bugger! does it:

https://github.com/sailfishos-chum/bugger/tree/master/quickaction

Step 1 is to make a file like this:

https://github.com/sailfishos-chum/bugger/blob/master/quickaction/jolla-settings/entries/harbour-bugger.json

and install it at /usr/share/jolla-settings/entries/

Step 1.1: create an appropriate icon for the top menu. I’d recommend downloading a suitable svg from Sailfish Icon Reference - Sailfish OS (you can do a save-as on the icon image) and modify it. You’ll need a ‘medium’ icon.

Step 2: as you can see in lower part of the .json file, your app is launched by calling a DBus method if the top menu entry is tapped.
So you need to provide this service.

The easiest way is to use Nemo.DBus and its DBusAdapter type in QML.
However, then the dbus call will only be available while the app is running.

To launch the app if it is not running, you need an ExecDBus line in your .desktop file, something like this:

ExecDBus=/usr/bin/invoker --type=silica-qt5 --id=harbour-bugger -- /usr/bin/sailfish-qml harbour-bugger --dbus

This triggers some useful magic in Sailjail and makes the app bus name known to Dbus. (If you are not using Sailjail, too bad, you’ll have to that part manually some way, among it writing a dbus .service file and installing that - again not harbour-compatible…)

You can see how I handle the topmenu method DBus call from QML here:

https://github.com/sailfishos-chum/bugger/blob/master/qml/harbour-bugger.qml#L187

4 Likes

Note that the recommendation is to do all the dbus adapter stuff in Qt/C++ to avoid race conditions.

If you want to go this route, a generic example is here:

https://codeberg.org/nephros/sfos-template-app/src/branch/master/src/fdo-activation.cpp

but I don’t do C++ very well and you should probably look at other apps’ code for this.

HTH!

1 Like

not that I recommend it, but in my Foil Notes app I chose to store unencrypted notes directly in the Jolla Notes database (and read them from there). of course that’s doable only from a non-jailed app. and of course it’s a hack which may stop working with any major SFOS update.

4 Likes

Is it some easy way to bring notes from notes app to notes plus app?

1 Like

Thanks a a lot for the explanation and examples. I want it to be harbour conform, but the idea of deploying a separate rpm may be a good middle ground for the time being.

Right, but it’s still an interesting solution.

Is it some easy way to bring notes from notes app to notes plus app?

Not right now. In v0.5.0, which I will release in the next few days, it will support plaintext notes though, which will make migration easier. I could provide a separate command or script to convert the Jolla Notes into text files. Then you can either migrate them at your own pace to adoc format (also possible via AI), or keep using them in plaintext format in Notes Plus.

1 Like