#!/usr/bin/env python3

import os
from pathlib import Path
from rofication import RoficationServer, NotificationQueue, RoficationDbusService

if __name__ == '__main__':
    queue_dir = os.path.expanduser('~/.cache/rofication')
    Path(queue_dir).mkdir(parents=True, exist_ok=True)

    queue_file = os.path.join(queue_dir, "notifications.json")
    not_queue = NotificationQueue.load(queue_file)
    service = RoficationDbusService(not_queue)

    with RoficationServer(not_queue) as server:
        server.start()
        try:
            service.run()
        except:
            server.shutdown()

    not_queue.save(queue_file)
