Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure notification service is available when sending a notification #720

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import options from '../options';
import { Astal, Gdk, Gtk } from 'astal/gtk3';
import AstalApps from 'gi://AstalApps?version=0.1';
import { exec, execAsync } from 'astal/process';
import { notifdService } from './constants/services.ts';

/**
* Handles errors by throwing a new Error with a message.
Expand Down Expand Up @@ -270,6 +271,12 @@ export function normalizePath(path: string): string {
* @param notifPayload The notification arguments containing summary, body, appName, iconName, urgency, timeout, category, transient, and id.
*/
export function Notify(notifPayload: NotificationArgs): void {
// This line does nothing useful at runtime, but when bundling, it
// ensures that notifdService has been instantiated and, as such,
// that the notification daemon is active and the notification
// will be handled
notifdService; // eslint-disable-line @typescript-eslint/no-unused-expressions

let command = 'notify-send';
command += ` "${notifPayload.summary} "`;
if (notifPayload.body) command += ` "${notifPayload.body}" `;
Expand Down
Loading