Skip to content

Instantly share code, notes, and snippets.

@mcepl
Last active February 14, 2021 10:46
Show Gist options
  • Save mcepl/0d5564dbf085c45adcb93b3498a3153d to your computer and use it in GitHub Desktop.
Save mcepl/0d5564dbf085c45adcb93b3498a3153d to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# usage: import-gsettings
import configparser
import os
import os.path
from gi import require_version
require_version('Gio', '2.0')
from gi.repository import Gio
translate_keys = {
'gtk-theme-name': 'gtk-theme',
'gtk-icon-theme-name': 'icon-theme',
'gtk-cursor-theme-name': 'cursor-theme',
'gtk-font-name': 'document-font-name',
'monospace-font-name': 'monospace-font-name',
}
config = configparser.ConfigParser()
config.read([
os.path.expandvars('$XDG_CONFIG_HOME/gtk-3.0/settings.ini'),
os.path.expanduser('~/.config/gtk-3.0/settings.ini')])
sect = config['Settings']
iface = Gio.Settings.new('org.gnome.desktop.interface')
for key in translate_keys:
iface.set_string(translate_keys[key], sect[key])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment