aboutsummaryrefslogtreecommitdiff
path: root/src/Notification.cpp
blob: 1201557d93091ebb3ca6e21b55e117cc289c59ee (plain)
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
#include "../include/Notification.hpp"
#include "../include/Program.h"
#include <assert.h>
#include <stdio.h>

namespace QuickMedia {
    const char* urgency_string(Urgency urgency) {
        switch(urgency) {
            case Urgency::LOW:
                return "low";
            case Urgency::NORMAL:
                return "normal";
            case Urgency::CRITICAL:
                return "critical";
        }
        assert(false);
        return nullptr;
    }

    void show_notification(const std::string &title, const std::string &description, Urgency urgency) {
        const char *args[] = { "notify-send", "-u", urgency_string(urgency), "--", title.c_str(), description.c_str(), nullptr };
        exec_program_async(args, nullptr);
        fprintf(stderr, "Notification: title: %s, description: %s\n", title.c_str(), description.c_str());
    }
}