Search code examples
gnome-shell-extensionsgjs

How to open extension prefs with DBus?


$ gnome-shell --version      
GNOME Shell 40.2

I'm trying to open extension prefs in gjs-console.

I found a way how to open prefs with dbus-send

dbus-send --session --print-reply --reply-timeout=2000 --type=method_call --dest=org.gnome.Shell.Extensions /org/gnome/Shell/Extensions org.gnome.Shell.Extensions.LaunchExtensionPrefs string:'text-translator'

But I stuck with gjs

  1. Run gjs-console
  2. Connect to bus proxy and call the method. PS you can try open prefs for any other extension you want, replace "text-translator" with you extension uuid "
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
dbus = Gio.DBusProxy.new_for_bus_sync(Gio.BusType.SESSION, Gio.DBusProxyFlags.NONE, null, "org.gnome.Shell", "/org/gnome/Shell/Extensions", "org.gnome.Shell.Extensions", null);
dbus.call_sync("LaunchExtensionPrefs", new GLib.Variant("(s)", [ "text-translator" ]), 0, -1, null);

But got this error:

typein:4:6 uncaught exception: Object
  @typein:4:6
  @<stdin>:1:42

Аnd I have no idea how to debug this.

My problem is to open my extension prefs from inside my extension. I'd be open to any help if there is any other way to do this.


Solution

  • My problem is to open my extension prefs from inside my extension.

    You can open it directly:

    Main.extensionManager.openExtensionPrefs('your-extension-uuid', '', {});