pydbus

https://travis-ci.org/LEW21/pydbus.svg?branch=master https://badge.fury.io/py/pydbus.svg

Pythonic DBus library.

Changelog: https://github.com/LEW21/pydbus/releases

Requirements

Examples

Send a desktop notification

from pydbus import SessionBus

bus = SessionBus()
notifications = bus.get('.Notifications')

notifications.Notify('test', 0, 'dialog-information', "Hello World!", "pydbus works :)", [], {}, 5000)

List systemd units

from pydbus import SystemBus

bus = SystemBus()
systemd = bus.get(".systemd1")

for unit in systemd.ListUnits():
    print(unit)

Start or stop systemd unit

from pydbus import SystemBus

bus = SystemBus()
systemd = bus.get(".systemd1")

job1 = systemd.StopUnit("ssh.service", "fail")
job2 = systemd.StartUnit("ssh.service", "fail")

Watch for new systemd jobs

from pydbus import SystemBus
from gi.repository import GLib

bus = SystemBus()
systemd = bus.get(".systemd1")

systemd.JobNew.connect(print)
GLib.MainLoop().run()

# or

systemd.onJobNew = print
GLib.MainLoop().run()

View object's API

from pydbus import SessionBus

bus = SessionBus()
notifications = bus.get('.Notifications')

help(notifications)

More examples & documentation

The Tutorial contains more examples and docs.