Created
December 15, 2014 16:28
-
-
Save freyes/9715b5d03fda53b1309f to your computer and use it in GitHub Desktop.
keep synced /desktop/ibus/general/preload-engines with /org/gnome/desktop/input-sources/sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from gi.repository import Gtk, Gio, GLib | |
IBUS_TO_GNOME = {'xkb:us::eng': ('xkbd', 'us'), | |
'xkb:us:intl:eng': ('xkbd', 'us+intl')} | |
def on_changed(settings, key): | |
if key != 'engines-order': | |
return | |
ibus_sources = settings.get_strv('preload-engines') | |
new_values = [] | |
for src in ibus_sources: | |
new_values.append(IBUS_TO_GNOME[src]) | |
print "ibus_sources:", ibus_sources | |
print "new_values:", new_values | |
gnome_input = Gio.Settings.new("org.gnome.desktop.input-sources") | |
gnome_input.set_value('sources', GLib.Variant('a(ss)', new_values)) | |
gnome_input.set_uint('current', 0) | |
setting = Gio.Settings.new("org.freedesktop.ibus.general") | |
setting.connect('changed', on_changed) | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment