- commit
- 6992a76818c92416492c34e59d479a3497df14c5
- parent
- cd6b737ca8f9204163d93457271c0b9334762658
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2026-02-16 08:57
add property API
Diffstat
| M | xibus/client.py | 35 | +++++++++++++++++++++++++++++++++++ |
1 files changed, 35 insertions, 0 deletions
diff --git a/xibus/client.py b/xibus/client.py
@@ -48,6 +48,16 @@ class Proxy: 48 48 async with self.client.subscribe_signal(*self.defaults, signal) as queue: 49 49 yield queue 50 50 -1 51 async def get_property(self, prop): -1 52 return await self.client.get_property(*self.defaults, prop) -1 53 -1 54 async def set_property(self, prop, value, sig=None): -1 55 return await self.client.set_property(*self.defaults, prop, value, sig) -1 56 -1 57 async def watch_property(self, prop): -1 58 async for value in self.client.watch_property(*self.defaults, prop): -1 59 yield value -1 60 51 61 52 62 class Client: 53 63 def __init__(self, con): @@ -95,3 +105,28 @@ class Client: 95 105 yield sq 96 106 finally: 97 107 await self.bus.call('RemoveMatch', [sq.rule], 's') -1 108 -1 109 async def get_property(self, name, path, iface, prop): -1 110 iprop = 'org.freedesktop.DBus.Properties' -1 111 result = await self.call(name, path, iprop, 'Get', (iface, prop), 'ss') -1 112 return result[1] -1 113 -1 114 async def set_property(self, name, path, iface, prop, value, sig=None): -1 115 iprop = 'org.freedesktop.DBus.Properties' -1 116 if sig is None: -1 117 schema = await self.introspect(name, path) -1 118 sig = schema.interfaces[iface].properties[prop].type -1 119 await self.call(name, path, iprop, 'Set', (iface, prop, (sig, value)), 'ssv') -1 120 -1 121 async def watch_property(self, name, path, iface, prop): -1 122 iprop = 'org.freedesktop.DBus.Properties' -1 123 async with self.subscribe_signal( -1 124 name, path, iprop, 'PropertiesChanged' -1 125 ) as queue: -1 126 yield await self.get_property(name, path, iface, prop) -1 127 async for _iface, changed, invalidated in queue: -1 128 if _iface == iface: -1 129 if prop in changed: -1 130 yield changed[prop][1] -1 131 elif prop in invalidated: -1 132 yield None