pi notify enhancements
This commit is contained in:
@@ -799,7 +799,7 @@ font_size 12.0
|
|||||||
|
|
||||||
#: Terminal bell {{{
|
#: Terminal bell {{{
|
||||||
|
|
||||||
# enable_audio_bell yes
|
enable_audio_bell yes
|
||||||
|
|
||||||
#: The audio bell. Useful to disable it in environments that require
|
#: The audio bell. Useful to disable it in environments that require
|
||||||
#: silence.
|
#: silence.
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ function notifyDesktop(
|
|||||||
const ICON_PATH = "/home/thomasgl/.pi/agent/extensions/assets/pi-logo.svg";
|
const ICON_PATH = "/home/thomasgl/.pi/agent/extensions/assets/pi-logo.svg";
|
||||||
|
|
||||||
function notify(title: string, body: string): void {
|
function notify(title: string, body: string): void {
|
||||||
|
// If in SSH session, use OSC escape sequences (they travel to client terminal)
|
||||||
|
if (isSSH()) {
|
||||||
|
// Try OSC 99 (Kitty) first if client might be Kitty, otherwise OSC 777
|
||||||
|
notifyOSC777(title, body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
notifyDesktop(title, body, ICON_PATH);
|
notifyDesktop(title, body, ICON_PATH);
|
||||||
return;
|
return;
|
||||||
@@ -74,8 +81,29 @@ function notify(title: string, body: string): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect if running in an SSH session
|
||||||
|
function isSSH(): boolean {
|
||||||
|
return !!(
|
||||||
|
process.env.SSH_CONNECTION ||
|
||||||
|
process.env.SSH_CLIENT ||
|
||||||
|
process.env.SSH_TTY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send BEL character - travels through SSH to client terminal
|
||||||
|
// Configure your terminal to play a sound on bell
|
||||||
|
function playBell(): void {
|
||||||
|
process.stdout.write("\x07");
|
||||||
|
}
|
||||||
|
|
||||||
// Sound playback
|
// Sound playback
|
||||||
function playSound(soundPath?: string): void {
|
function playSound(soundPath?: string): void {
|
||||||
|
// If in SSH session, send BEL to client terminal instead of playing locally
|
||||||
|
if (isSSH()) {
|
||||||
|
playBell();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { execFile } = require("child_process");
|
const { execFile } = require("child_process");
|
||||||
|
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
|
|||||||
Reference in New Issue
Block a user