#!/usr/bin/env python3

import sys
import time

from mac_notifications import client


class Callback:
    def __init__(self):
        self.called_back = False

    def callback(self):
        self.called_back = True

    def __str__(self):
        if self.called_back:
            return 'callback called'
        else:
            return 'callback not called'

    __repr__ = __str__


if __name__ == '__main__':
    for i in range(2):
        cb = Callback()
        client.create_notification(
            title="title {}".format(i),
            subtitle="subtitle",
            icon=None,
            action_button_str="Acknowledge",
            action_callback=cb.callback,
        )
        while not cb.called_back:
            print('waiting...')
            sys.stdout.flush()
            time.sleep(1)
        client.stop_listening_for_callbacks()
    print('hello!')