mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
This patch modifies our stdout reader to consume input as we go, instead of all at once when stdout is closed. This will make it easier to add support for reading e.g. the daemon assigned notification ID in the future, and also ensures we see the XDG activation token "as soon as possible". Furthermore, to be more future proof, require the XDG activation token to be prefixed with 'xdgtoken=', and ignore other lines. Thus, instead of treating *all* of stdout as the XDG activation token, parse stdout line-by-line, and ignore everything that does not begin with 'xdgtoken='. Everything (on that line) following 'xdgtoken=' is treated as the activation token.
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
#pragma once
|
|
#include <stdbool.h>
|
|
#include <unistd.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;
|
|
char *title;
|
|
char *body;
|
|
char *icon;
|
|
|
|
enum notify_when when;
|
|
enum notify_urgency urgency;
|
|
bool focus;
|
|
bool report;
|
|
|
|
/*
|
|
* Used internally by notify
|
|
*/
|
|
|
|
char *xdg_token; /* XDG activation token, from daemon */
|
|
|
|
pid_t pid; /* Notifier command PID */
|
|
int stdout_fd; /* Notifier command's stdout */
|
|
|
|
char *stdout; /* Data we've reado from command's stdout */
|
|
size_t stdout_sz;
|
|
};
|
|
|
|
bool notify_notify(const struct terminal *term, struct notification *notif);
|
|
void notify_free(struct terminal *term, struct notification *notif);
|