Import native libraries into the shell process?

Hello,

I’m considering writing a search provider for a 3rd party application which stores the data of interest in an sqlite database. I know that I can read an sqlite database with libgda6 which conveniently even has a Gjs example for sqlite in its code tree.

However, in my understanding importing gir://Gda in a shell extension would also load the corresponding native shared library into the shell process. If my understanding is correct, is this a good idea?

Or should I rather write a separate Gjs script which loads the relevant data and dumps it on stdout, e.g. as JSON, and then call this script as a subprocess from the extension, to avoid polluting the extension process with the shared library?

Cheers,
Basti

You should just import the library. The only thing you really want to be concerned with in cases like this is overloading the main thread, since this is where animations and user interaction are running.

Offloading things to subprocesses should generally be avoided, unless unavoidable (obviously), or it makes sense for the use case.

1 Like

If your extension involves querying a database are you sure you don’t want to write an application instead? You can still write it in JavaScript, and distribution of applications is a lot easier, these days.

Search providers don’t need to be extensions either: you can implement the provider D-Bus API in your own application and give results to the Shell across process boundaries.

2 Likes

You should just import the library

Thanks, then I’ll just do that.

If your extension involves querying a database are you sure you don’t want to write an application instead?

I think I am, yes. As said, I’d like to add a search provider for a 3rd party application, and I don’t think I’d like to write an application just to provide search for an application…

Search providers don’t need to be extensions either: you can implement the provider D-Bus API in your own application and give results to the Shell across process boundaries.

I know; I’ve written external search providers (as systemd user services) already. But those are harder to distribute, also because the shell doesn’t read search provider definitions from ~/.local/share/gnome-shell.

libgda and libvda, are libraries you can use in your Gjs scripts, just import the GIR.

If you want to create a JSON to GObject mapping with a little effort, you can write a library in Vala using libgvo, with a simple syntax, generate the correspoding GIR/TYPELIB so you can easy parse JSON files to GObject properties, then use it on Gjs/Python/C/Vala. When using libvda or libgda, you write once and use with other database providers.

Think on a search provider using an enterprise search engine using PostgreSQL for data storage, while a good idea will be to add to libvda support on Apache Arrow for large data storages.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.