Skip to content

Instantly share code, notes, and snippets.

@teward
Forked from SergKolo/dbus_send_python.py
Last active June 30, 2016 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teward/52a7f58ec94a1e3652831ebf95418912 to your computer and use it in GitHub Desktop.
Save teward/52a7f58ec94a1e3652831ebf95418912 to your computer and use it in GitHub Desktop.
python
import dbus
def get_dbus(obj, path, interface, method):
# This basically works the same as
# dbus-send or qdbus. Just give it
# all the info, and it will spit out output
bus = dbus.SessionBus()
proxy = bus.get_object(obj, path)
method = proxy.get_dbus_method(method, interface)
return method()
windows = get_dbus('org.ayatana.bamf', '/org/ayatana/bamf/matcher', 'org.ayatana.bamf.matcher', 'WindowPaths')
for window in windows:
print get_dbus('org.ayatana.bamf', window, 'org.ayatana.bamf.view', 'Name')
@teward
Copy link
Author

teward commented Jun 30, 2016

Style is important, all must obey PEP8! Jon Skeet endorses PEP8 you know!

PEP8: https://www.python.org/dev/peps/pep-0008/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment