Is it possible to add an entry to Desktop's context menu?

In the process of writing a Shell extension, I’m looking for a way to add a new entry to the context menu prompted in Gnome’s desktop (where by default only “Change Background”, “Display Settings” and “Settings” are available), as well as - ideally - capturing the cursor coordinates; is it possible? I’m skimming through GJS documentation and have found nothing about it.

Don’t know the answer, but that menu’s code is here: js/ui/backgroundMenu.js · main · GNOME / gnome-shell · GitLab

For reference, I was able to achieve this by grabbing the background menu object from the current layout manager:

    let backgroundMenu = Main.layoutManager._bgManagers[0].backgroundActor._backgroundMenu;

    let extraMenuItem = new PopupMenu.PopupMenuItem(_('Something'));
    extraMenuItem.connect('activate', () => {  /* do stuff */  });

    backgroundMenu.addMenuItem(extraMenuItem, 0);

But to be honest, it’s hardly a straightforward way to implement this; the background menu isn’t exported as a conventional GObject as most other UI elements, and I’m unsure what that entails from a development perspective.

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