Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Dec 7, 2023
1 parent aa43cef commit 787e319
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions flatpak/workaround/process_monitor.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 787e319

Please sign in to comment.