31 lines
799 B
Python
31 lines
799 B
Python
"""Test-only GTK client: query live settings over stdin on an owned X server."""
|
|
import sys
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "3.0")
|
|
from gi.repository import Gtk, GLib
|
|
|
|
Gtk.init([])
|
|
settings = Gtk.Settings.get_default()
|
|
properties = ("gtk-cursor-theme-name", "gtk-cursor-theme-size", "gtk-theme-name",
|
|
"gtk-icon-theme-name", "gtk-font-name")
|
|
|
|
|
|
def reply():
|
|
print("|".join(str(settings.get_property(name)) for name in properties), flush=True)
|
|
return False
|
|
|
|
|
|
def request(source, condition):
|
|
if not sys.stdin.readline():
|
|
Gtk.main_quit()
|
|
return False
|
|
# Give queued X notifications a chance to dispatch before answering.
|
|
GLib.timeout_add(20, reply)
|
|
return True
|
|
|
|
|
|
GLib.io_add_watch(sys.stdin, GLib.IO_IN | GLib.IO_HUP, request)
|
|
reply()
|
|
Gtk.main()
|