2

I'm using Gnome on a tablet as a daily driver. The integrated virtual keyboard doesn't serve as a replacement for a real keyboard, but I need exactly that. Thus I want to replace it with Onboard, and started to write an extension for Gnome Shell. The goal is to hide and show Onboard when the integrated virtual keyboard would be hidden/shown.

I can show/hide Onboard through DBus like this:

dbus-send --type=method_call --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Show

I adapted the example at https://wiki.gnome.org/Gjs/Examples/DBusClient to test showing/hiding Onboard through DBus:

const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;

// This the D-Bus interface as XML
const OnboardInterface = '<node> \
  <interface name="org.onboard.Onboard.Keyboard"> \
    <method name="ToggleVisible"> \
    </method> \
    <method name="Show"> \
    </method> \
    <method name="Hide"> \
    </method> \
  </interface> \
</node>';

// Declare the proxy class based on the interface
const OnboardProxy = Gio.DBusProxy.makeProxyWrapper(OnboardInterface);

let OnbProxy = new OnboardProxy(
    Gio.DBus.system,
    "org.onboard.Onboard",
    "/org/onboard/Onboard/Keyboard"
);

OnbProxy.ShowSync()

let loop = new GLib.MainLoop(null, false);
loop.run();

Sadly it doesn't show Onboard, instead throws this error:

$ gjs ./test.js 
(gjs:13144): Gjs-WARNING **: JS ERROR: Gio.DBusError: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.onboard.Onboard was not provided by any .service files
_proxyInvoker@resource:///org/gnome/gjs/modules/overrides/Gio.js:98
_makeProxyMethod/<@resource:///org/gnome/gjs/modules/overrides/Gio.js:124
@./test.js:26

JS_EvaluateScript() failed

I have no clue why it talks about services when all I wan't to do is sending a message trough DBus? It's probably a rather stupid mistake as I don't have any experience with either Gnome Shell extensions nor DBus..

Version of Gnome is 3.18.0

4

1 回答 1

3

找到解决方案:用 Gio.DBus.session 替换 Gio.DBus.system

Onboard 不是系统服务,而是在用户会话中启动的,因此它不起作用。

一旦验证通过,扩展将在https://extensions.gnome.org/上可用,只需搜索“板载集成”。我也做了另一个相关的,“键盘滑动”按照它说的做(从底部滑动)

于 2015-10-11T22:03:14.753 回答