Skip to content

Instantly share code, notes, and snippets.

@KeenS
Created December 12, 2021 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeenS/600d8f4e669c6f55a7b52c69f52b9673 to your computer and use it in GitHub Desktop.
Save KeenS/600d8f4e669c6f55a7b52c69f52b9673 to your computer and use it in GitHub Desktop.
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gio
from gi.repository import GLib
conn = Gio.DBusProxy.new_for_bus_sync(
Gio.BusType.SESSION,
Gio.DBusProxyFlags.NONE,
# info
None,
#name
"org.gnome.Shell",
# object path
"/org/gnome/Shell",
# interface_name
"org.gnome.Shell",
# cancellable
None,
)
print(conn)
expr = "global.get_window_actors().findIndex(a=>a.meta_window.has_focus()===true)"
ret = conn.call_sync(
"Eval",
GLib.Variant.new_tuple(GLib.Variant.new_string(expr)),
Gio.DBusCallFlags.NONE,
-1,
None,
)
print(ret)
index = ret[1]
expr = "global.get_window_actors()[%s].get_meta_window().get_wm_class()" % index
ret = conn.call_sync(
"Eval",
GLib.Variant.new_tuple(GLib.Variant.new_string(expr)),
Gio.DBusCallFlags.NONE,
-1,
None,
)
print(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment