From 53ddb0571f79050610e443f7fae7c454bccf5ed7 Mon Sep 17 00:00:00 2001 From: RedBearAK <64876997+RedBearAK@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:51:24 -0900 Subject: [PATCH 1/4] Add test script for Pantheon/Gala signals --- wlroots-dev/pantheon_dbus_signal_monitor.py | 65 +++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 wlroots-dev/pantheon_dbus_signal_monitor.py diff --git a/wlroots-dev/pantheon_dbus_signal_monitor.py b/wlroots-dev/pantheon_dbus_signal_monitor.py new file mode 100755 index 0000000..df8b4b0 --- /dev/null +++ b/wlroots-dev/pantheon_dbus_signal_monitor.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +from gi.repository import GLib +import dbus +import dbus.mainloop.glib + +class GalaMonitor: + def __init__(self): + self.bus = None + self.gala_interface = None + + def connect_to_gala(self): + try: + self.bus = dbus.SessionBus() + self.gala_interface = self.bus.get_object( + "org.pantheon.gala.DesktopIntegration", + "/org/pantheon/gala/DesktopInterface" + ) + print("Connected to Gala D-Bus interface.") + except Exception as e: + print(f"Failed to connect to Gala interface: {e}") + return False + return True + + def on_windows_changed(self, *args): + print("WindowsChanged signal received.") + + def on_running_apps_changed(self, *args): + print("RunningApplicationsChanged signal received.") + + def subscribe_signals(self): + try: + self.bus.add_signal_receiver( + self.on_windows_changed, + signal_name="WindowsChanged", + dbus_interface="org.pantheon.gala.DesktopIntegration", + path="/org/pantheon/gala/DesktopInterface" + ) + + self.bus.add_signal_receiver( + self.on_running_apps_changed, + signal_name="RunningApplicationsChanged", + dbus_interface="org.pantheon.gala.DesktopIntegration", + path="/org/pantheon/gala/DesktopInterface" + ) + + print("Subscribed to WindowsChanged and RunningApplicationsChanged signals.") + except Exception as e: + print(f"Failed to subscribe to signals: {e}") + + def run(self): + if not self.connect_to_gala(): + return + self.subscribe_signals() + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + loop = GLib.MainLoop() + print("Listening for signals... Press Ctrl+C to exit.") + try: + loop.run() + except KeyboardInterrupt: + print("Exiting...") + +if __name__ == "__main__": + monitor = GalaMonitor() + monitor.run() From 1e5637f6450f880025560a47c8708dfb714b2277 Mon Sep 17 00:00:00 2001 From: RedBearAK <64876997+RedBearAK@users.noreply.github.com> Date: Thu, 28 Nov 2024 19:37:49 -0900 Subject: [PATCH 2/4] Working version of test Pantheon module --- wlroots-dev/pantheon_dbus_signal_monitor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wlroots-dev/pantheon_dbus_signal_monitor.py b/wlroots-dev/pantheon_dbus_signal_monitor.py index df8b4b0..2dbdf92 100755 --- a/wlroots-dev/pantheon_dbus_signal_monitor.py +++ b/wlroots-dev/pantheon_dbus_signal_monitor.py @@ -1,5 +1,8 @@ #!/usr/bin/env python3 +# Works, but the signals are not useful for tracking the active app class and window title. + + from gi.repository import GLib import dbus import dbus.mainloop.glib @@ -11,9 +14,11 @@ def __init__(self): def connect_to_gala(self): try: + # Ensure the main loop is set before creating the session bus + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) self.bus = dbus.SessionBus() self.gala_interface = self.bus.get_object( - "org.pantheon.gala.DesktopIntegration", + "org.pantheon.gala", "/org/pantheon/gala/DesktopInterface" ) print("Connected to Gala D-Bus interface.") @@ -52,7 +57,6 @@ def run(self): if not self.connect_to_gala(): return self.subscribe_signals() - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) loop = GLib.MainLoop() print("Listening for signals... Press Ctrl+C to exit.") try: From 1c0f38f76d84bd28d1dcf06d248700a04a6c7c07 Mon Sep 17 00:00:00 2001 From: RedBearAK <64876997+RedBearAK@users.noreply.github.com> Date: Thu, 28 Nov 2024 22:42:00 -0900 Subject: [PATCH 3/4] Identify Pantheon window manager (Gala) --- lib/env_context.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/env_context.py b/lib/env_context.py index 2b238d0..101a119 100644 --- a/lib/env_context.py +++ b/lib/env_context.py @@ -567,6 +567,7 @@ def get_window_manager(self): 'i3-gaps': 'i3', 'miracle-wm': 'miracle-wm', 'openbox': 'openbox', + 'pantheon': 'gala', 'sway': 'sway', 'xfce': 'xfwm4', From 77d59027076b7fb6eae91b748ae26b762b1c7363 Mon Sep 17 00:00:00 2001 From: RedBearAK <64876997+RedBearAK@users.noreply.github.com> Date: Thu, 28 Nov 2024 23:12:51 -0900 Subject: [PATCH 4/4] Notes about Pantheon Wayland support --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7e242b8..6455cab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Current status: Stable Beta (Please Read) +**2024-11-28 UPDATE**: Added support for Pantheon's Wayland session (elementary OS desktop environment). + **2024-10-03 UPDATE**: Fixed the broken COSMIC desktop environment support to work with COSMIC Alpha 2 or later (unless they change the relevant Wayland protocol again). **2024-07-28 UPDATE**: Some basic `wlroots` based Wayland compositor support has been added. See the [Wiki article](https://github.com/RedBearAK/toshy/wiki/Wlroots-Based-Wayland-Compositors). @@ -357,6 +359,7 @@ You will find these distro groupings in the Wiki article: - **Hyprland** - _[currently uses `hyprpy` Python module]_ - **MiracleWM** - _[via `wlroots` method]_ - **Niri** - _[via `wlroots` method]_ + - **Pantheon** - [via D-Bus queries to Gala WM] - **Plasma 5 (KDE)** - _[uses custom KWin script and D-Bus service]_ - **Plasma 6 (KDE)** - _[uses custom KWin script and D-Bus service]_ - **Qtile** - _[via `wlroots` method]_