-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotify.h
92 lines (72 loc) · 2.63 KB
/
notify.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
#include <tllist.h>
struct terminal;
enum notify_when {
/* First, so that it can be left out of initializer and still be
the default */
NOTIFY_ALWAYS,
NOTIFY_UNFOCUSED,
NOTIFY_INVISIBLE
};
enum notify_urgency {
/* First, so that it can be left out of initializer and still be
the default */
NOTIFY_URGENCY_NORMAL,
NOTIFY_URGENCY_LOW,
NOTIFY_URGENCY_CRITICAL,
};
struct notification {
/*
* Set by caller of notify_notify()
*/
char *id; /* Internal notification ID */
char *app_id; /* Custom app-id, overrides the terminal's app-id if set */
char *title; /* Required */
char *body;
char *category;
enum notify_when when;
enum notify_urgency urgency;
int32_t expire_time;
tll(char *) actions;
char *icon_cache_id;
char *icon_symbolic_name;
uint8_t *icon_data;
size_t icon_data_sz;
bool focus; /* Focus the foot window when notification is activated */
bool may_be_programatically_closed; /* OSC-99: notification may be programmatically closed by the client */
bool report_activated; /* OSC-99: report notification activation to client */
bool report_closed; /* OSC-99: report notification closed to client */
/*
* Used internally by notify
*/
uint32_t external_id; /* Daemon assigned notification ID */
bool activated; /* User 'activated' the notification */
uint32_t button_count; /* Number of buttons (custom actions) in notification */
uint32_t activated_button; /* User activated one of the custom actions */
char *xdg_token; /* XDG activation token, from daemon */
pid_t pid; /* Notifier command PID */
int stdout_fd; /* Notifier command's stdout */
char *stdout_data; /* Data we've reado from command's stdout */
size_t stdout_sz;
/* Used when notification provides raw icon data, and it's
bypassing the icon cache */
char *icon_path;
int icon_fd;
};
struct notification_icon {
char *id;
char *symbolic_name;
char *tmp_file_name;
int tmp_file_fd;
};
bool notify_notify(struct terminal *term, struct notification *notif);
void notify_close(struct terminal *term, const char *id);
void notify_free(struct terminal *term, struct notification *notif);
void notify_icon_add(struct terminal *term, const char *id,
const char *symbolic_name, const uint8_t *data,
size_t data_sz);
void notify_icon_del(struct terminal *term, const char *id);
void notify_icon_free(struct notification_icon *icon);