Snap GNOME Extension

Hi all,

A long time ago I wrote Snap Manager extension.
That was not really clean but it worked.
I got a suggestion to use API (was @popey ? @ogra , well I cannot remember).

So many years later…

(yes – a new one, just starting, not yet published).

I experienced odd results if no refresh/changes are available, but that’s ok now.
But I cannot figure out how to listen to installed snaps changes. I obviously could listen to Shell’s appsystem changes but not all snaps are apps.
https://gjs-docs.gnome.org/snapd2~2/

Summary: help needed from snap experts!
:sweat_smile:

Hi. You can use the snapd-notices-monitor object to obtain events from the system. It will send signals every time a notice or an error event happens. I can’t point you to the online documentation because there is a problem ATM in the wiki.

2 Likes

BTW: it seems that the documentation in GJS page is old…

1 Like

This seems fine Snapd.NoticesMonitor - Classes - Snapd 2

Although it’s for python, but it maps pretty well to JS objects

2 Likes

Hey, it works!! Thanks for this gjs-ghosted class. :sweat_smile:

1 Like

Is there a default Adwaita snap symbolic icon?
I did not see it (just Yaru’s that I use) in my Debian 13.

Did I clean correctly the snapd objects in destroy() ?
They do not have a destroy method, so I just nulled them out.

Nulling them should be enough: being GObjects, when the garbage collector detects that the object has no references, will call to g_object_unref().

Hmm, there’s in fact an issue:
because of this._snapdNoticesMonitor?.start();, the function _getChanges() do not do anything. It is triggered, so no problem from this side, but the get_changes_async is not executed or at least it does not display changes anymore.

Try using a different snapd client for the monitor than for the changes. The monitor blocks the client socket.

Ok that’s what I intended to make but I was waiting first your answer.

Using two different snapd clients works.

1 Like

Ok, so there is atm no advanced snap infos nor features, but it works (dialogs for remove/install/infos…). Yes I will use dialogs rather than notifications, that’s not a big deal. :slight_smile:

There is one thing I don’t know, that’s how to make the menu scrollable if too long. And some people have a LOT of snaps.

1 Like

Ok. The extension is now in a quite decent state.

I experience an issue with:
const channels = snap?.channels?.map(channel => channel.name).join(' ')

  • the channels property returns JS ERROR: Error: Unknown signal in logs
  • if I use get_channels() it does not return any error but I get a void list

I got a similar issue using const apps = snap?.get_apps() as I cannot use simply snap?.apps.

Help! :slight_smile:

It’s online now:

https://extensions.gnome.org/extension/9040/snap-menu/

Thank you for your contributions to the community, it is much appreciated.

May I make a suggestion?

I think it would be useful to add some screenshots either over at GNOME extensions or the GitHub page.

Just something to consider :slight_smile:

1 Like

Done! :slight_smile: _________________________

1 Like

Of course the final goal is to have much more infos and features.
But let’s begin with something.

And I need channels for some features (change channel, of course!).

How can I get all the available channels for a snap?
I can’t make get_channels() to work.

I see you asked over at the Snapcraft forums already (or at least something similar?).

That is the proper place for these types of questions and where you are likely to get the best support.

In any event, good luck :pray:

Yes! but I did not get any reply, so my channels array is definitely void. :wink:
I don’t know if it’s a library bug or a misuse by me.