gjs-gio - org.fcitx.Fcitx
Script
- get-current-im.js
#!/usr/bin/env gjs
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
let bus = Gio.bus_get_sync(Gio.BusType.SESSION, null)
let rtn = bus.call_sync(
'org.fcitx.Fcitx', //bus_name
'/inputmethod', //object_path
'org.fcitx.Fcitx.InputMethod', //interface_name
'GetCurrentIM', //method_name
null, // parameters
GLib.VariantType.new('(s)'), //reply_type
Gio.DBusCallFlags.NONE, //flags
-1, //timeout_msec
null //cancellable
)
print(rtn.print(true));
//print(rtn.deep_unpack()[0]);
- set-current-im.js
#!/usr/bin/env gjs
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
let bus = Gio.bus_get_sync(Gio.BusType.SESSION, null)
let rtn = bus.call_sync(
'org.fcitx.Fcitx', //bus_name
'/inputmethod', //object_path
'org.fcitx.Fcitx.InputMethod', //interface_name
'SetCurrentIM', //method_name
GLib.Variant.new('(s)', ['fcitx-keyboard-us']), // parameters
GLib.VariantType.new('()'), //reply_type
Gio.DBusCallFlags.NONE, //flags
-1, //timeout_msec
null //cancellable
)
print(rtn.print(true));
//print(rtn.deep_unpack());
- set-current-im-chewing.js
#!/usr/bin/env gjs
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
let bus = Gio.bus_get_sync(Gio.BusType.SESSION, null)
let rtn = bus.call_sync(
'org.fcitx.Fcitx', //bus_name
'/inputmethod', //object_path
'org.fcitx.Fcitx.InputMethod', //interface_name
'SetCurrentIM', //method_name
GLib.Variant.new('(s)', ['chewing']), // parameters
GLib.VariantType.new('()'), //reply_type
Gio.DBusCallFlags.NONE, //flags
-1, //timeout_msec
null //cancellable
)
print(rtn.print(true));
//print(rtn.deep_unpack());
使用範例
執行
$ ./get-current-im.js
顯示
('fcitx-keyboard-us',)
執行
$ ./set-current-im-chewing.js
顯示
()
執行
$ ./get-current-im.js
顯示
('chewing',)
執行
$ ./set-current-im.js
顯示
()
執行
$ ./get-current-im.js
顯示
('fcitx-keyboard-us',)