summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/system.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/utils/system.ts b/src/utils/system.ts
index 5d77908..1c5f011 100644
--- a/src/utils/system.ts
+++ b/src/utils/system.ts
@@ -10,6 +10,28 @@ export const launch = (app: AstalApps.Application) => {
app.frequency++;
};
+export const notify = (props: {
+ summary: string;
+ body?: string;
+ icon?: string;
+ urgency?: "low" | "normal" | "critical";
+ transient?: boolean;
+ actions?: Record<string, () => void>;
+}) =>
+ execAsync([
+ "notify-send",
+ "-a",
+ "caelestia-shell",
+ ...(props.icon ? ["-i", props.icon] : []),
+ ...(props.urgency ? ["-u", props.urgency] : []),
+ ...(props.transient ? ["-e"] : []),
+ ...Object.keys(props.actions ?? {}).flatMap((k, i) => ["-A", `${i}=${k}`]),
+ props.summary,
+ ...(props.body ? [props.body] : []),
+ ])
+ .then(action => props.actions && Object.values(props.actions)[parseInt(action, 10)]?.())
+ .catch(console.error);
+
export const osId = GLib.get_os_info("ID") ?? "unknown";
export const osIdLike = GLib.get_os_info("ID_LIKE");
export const osIcon = String.fromCodePoint(