gnome - 用 Onboard -> Hide/Show via DBus 替换 Gnomes 虚拟键盘不起作用

标签 gnome dbus gnome-shell gjs gdbus

我在平板电脑上使用 Gnome 作为日常驱动程序。集成的虚拟键盘不能替代真实的键盘,但我正是需要它。于是我想用Onboard来代替它,并开始为Gnome Shell编写一个扩展。目标是在隐藏/显示集成虚拟键盘时隐藏和显示 Onboard。

我可以通过 DBus 显示/隐藏 Onboard,如下所示:

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

我改编了 https://wiki.gnome.org/Gjs/Examples/DBusClient 中的示例通过 DBus 测试显示/隐藏 Onboard:

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();

遗憾的是它没有显示 Onboard,而是抛出此错误:

$ 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

我不知道为什么它谈论服务,而我只想通过 DBus 发送消息?这可能是一个相当愚蠢的错误,因为我对 Gnome Shell 扩展和 DBus 都没有任何经验..

Gnome 版本为 3.18.0

最佳答案

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

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

该扩展程序将在https://extensions.gnome.org/上可用一旦验证通过,只需搜索“板载集成”即可。我还做了另一个相关的,“键盘滑动”正如它所说的那样(从底部滑动)

关于gnome - 用 Onboard -> Hide/Show via DBus 替换 Gnomes 虚拟键盘不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33065735/

相关文章:

linux - 使用远程连接在 CentOS 6.4 上运行 Gnome 不起作用

rust - 如何使用 zbus 列出 block 设备?

automated-tests - 用于集成测试 Gnome-Shell 扩展的工具?

focus - GNOME Shell 中非事件/未聚焦窗口的透明度/亮度

python - 如何使用 pygtk 获取 gnome2 桌面上所有窗口的列表?

Java:JFrame.setLocationRelativeTo(null) 在 Ubuntu 10.04/gnome 2.30.2 和 OpenJDK 1.6.0_18 上不使窗口居中

c++ - dbus - 如何设置包含路径

python-3.x - 飞溅问题(d-bus,QSslSocket,libpng)

linux - gnome shell 3.16 - 如何添加重启按钮

gnome - 禁用 Gnome 经典桌面热点