Created
December 12, 2021 16:06
-
-
Save KeenS/600d8f4e669c6f55a7b52c69f52b9673 to your computer and use it in GitHub Desktop.
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
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