summaryrefslogtreecommitdiff
path: root/resteasy-desktop/libexec/resteasy-desktop-monitor
blob: 867eb5d4db3ec2b50efade0faae94fcad6938a3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import subprocess
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
from gi.repository import GLib
from pydbus.generic import signal
from pydbus import SystemBus

loop = GLib.MainLoop()
bus = SystemBus()


def handle_signal(sender, object, iface, signal, args):
    message = str(args[0])
    Notify.init("resteasy")
    notification = Notify.Notification.new("resteasy", message,
                                           "drive-harddisk")
    notification.set_urgency(
        2
    )  # 2 highest level, shouldn't go away until a user acknowledges the message
    notification.show()
    subprocess.call(["pkill", "-SIGRTMIN+10", "i3blocks"])


if __name__ == "__main__":
    # subscribe to bus to monitor for server signal emissions
    bus.subscribe(object="/io/crashbox/resteasy/Main",
                  iface="io.crashbox.resteasy.Info",
                  signal_fired=handle_signal)
    loop.run()