From 787e3198bd2ebc9473dce67610d45e588a1d13d3 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:18:26 +0100 Subject: [PATCH] . --- flatpak/workaround/process_monitor.py | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 flatpak/workaround/process_monitor.py diff --git a/flatpak/workaround/process_monitor.py b/flatpak/workaround/process_monitor.py new file mode 100644 index 00000000..78bc9ea7 --- /dev/null +++ b/flatpak/workaround/process_monitor.py @@ -0,0 +1,35 @@ +import os + +import dbus +import dbus.service +import dbus.mainloop.glib +from gi.repository import GLib + + +def get_pids(): + # Define the path to the directory + path = '/proc' + + # Get a list of all directories in the path + directories = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))] + + # Filter out directories that contain only numbers in their names + return [d for d in directories if d.isnumeric()] + + +class HelloWorld(dbus.service.Object): + def __init__(self, conn=None, object_path=None, bus_name=None): + dbus.service.Object.__init__(self, conn, object_path, bus_name) + + @dbus.service.method(dbus_interface="com.github.stsdc.monitor.workaround.GetProcesses", in_signature="s", out_signature="as", sender_keyword="sender", connection_keyword="conn") + def get_processes(self, name, sender=None, conn=None): + return get_pids() + +if __name__ == "__main__": + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + bus = dbus.SessionBus() + name = dbus.service.BusName("com.github.stsdc.monitor.workaround", bus) + helloworld = HelloWorld(bus, "/processes") + mainloop = GLib.MainLoop() + mainloop.run() +