fix notifications
This commit is contained in:
@@ -9,13 +9,18 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|||||||
|
|
||||||
// ============ CONFIGURATION ============
|
// ============ CONFIGURATION ============
|
||||||
const REMOTE_HOST = "linux-pc"; // SSH host for remote notifications
|
const REMOTE_HOST = "linux-pc"; // SSH host for remote notifications
|
||||||
const REMOTE_COMMAND = "paplay /usr/share/sounds/freedesktop/stereo/window-attention.oga & notify-send -i ~/.pi/agent/extensions/assets/pi-logo.svg 'Pi' 'Done. Ready for input.'";
|
const REMOTE_COMMAND =
|
||||||
|
"paplay /usr/share/sounds/freedesktop/stereo/window-attention.oga & notify-send -i ~/.pi/agent/extensions/assets/pi-logo.svg 'Pi' 'Done. Ready for input.'";
|
||||||
const LOCAL_SOUND_MAC = "/System/Library/Sounds/Glass.aiff";
|
const LOCAL_SOUND_MAC = "/System/Library/Sounds/Glass.aiff";
|
||||||
const LOCAL_SOUND_LINUX = "/usr/share/sounds/freedesktop/stereo/complete.oga";
|
const LOCAL_SOUND_LINUX = "/usr/share/sounds/freedesktop/stereo/complete.oga";
|
||||||
// =======================================
|
// =======================================
|
||||||
|
|
||||||
function isSSH(): boolean {
|
function isSSH(): boolean {
|
||||||
if (process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY) {
|
if (
|
||||||
|
process.env.SSH_CONNECTION ||
|
||||||
|
process.env.SSH_CLIENT ||
|
||||||
|
process.env.SSH_TTY
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check for sshd-session process (works in tmux/zellij)
|
// Check for sshd-session process (works in tmux/zellij)
|
||||||
@@ -33,7 +38,10 @@ function isSSH(): boolean {
|
|||||||
|
|
||||||
function notifyRemote(): void {
|
function notifyRemote(): void {
|
||||||
const { exec } = require("child_process");
|
const { exec } = require("child_process");
|
||||||
exec(`ssh -o ConnectTimeout=2 -o BatchMode=yes ${REMOTE_HOST} "${REMOTE_COMMAND}"`, { timeout: 5000 });
|
exec(
|
||||||
|
`ssh -o ConnectTimeout=2 -o BatchMode=yes ${REMOTE_HOST} "${REMOTE_COMMAND}"`,
|
||||||
|
{ timeout: 5000 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyLocal(): void {
|
function notifyLocal(): void {
|
||||||
@@ -41,18 +49,29 @@ function notifyLocal(): void {
|
|||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
execFile("afplay", [LOCAL_SOUND_MAC]);
|
execFile("afplay", [LOCAL_SOUND_MAC]);
|
||||||
} else if (process.platform === "linux") {
|
} else if (process.platform === "linux") {
|
||||||
exec("paplay /usr/share/sounds/freedesktop/stereo/window-attention.oga & notify-send -i ~/.pi/agent/extensions/assets/pi-logo.svg 'Pi' 'Done. Ready for input.'");
|
execFile(
|
||||||
|
"paplay",
|
||||||
|
["/usr/share/sounds/freedesktop/stereo/window-attention.oga"],
|
||||||
|
(err: any) => {
|
||||||
|
if (err) console.error("paplay error:", err);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
exec(
|
||||||
|
"notify-send -i ~/.pi/agent/extensions/assets/pi-logo.svg 'Pi' 'Done. Ready for input.'",
|
||||||
|
(err: any) => {
|
||||||
|
if (err) console.error("notify-send error:", err);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendNotification(): void {
|
function sendNotification(): void {
|
||||||
// On Mac or SSH session: notify remote Linux
|
|
||||||
// On Linux locally: notify local
|
|
||||||
if (process.platform === "darwin" || isSSH()) {
|
if (process.platform === "darwin" || isSSH()) {
|
||||||
notifyRemote();
|
notifyRemote();
|
||||||
} else {
|
|
||||||
notifyLocal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always notify locally too
|
||||||
|
notifyLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function (pi: ExtensionAPI) {
|
export default function (pi: ExtensionAPI) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"lastChangelogVersion": "0.54.2",
|
"lastChangelogVersion": "0.55.0",
|
||||||
"defaultProvider": "anthropic",
|
"defaultProvider": "openrouter",
|
||||||
"defaultModel": "claude-opus-4-5",
|
"defaultModel": "google/gemini-2.5-flash",
|
||||||
"defaultThinkingLevel": "medium",
|
"defaultThinkingLevel": "off",
|
||||||
"theme": "matugen",
|
"theme": "matugen",
|
||||||
"packages": [
|
"packages": [
|
||||||
"npm:pi-mcp-adapter"
|
"npm:pi-mcp-adapter"
|
||||||
|
|||||||
Reference in New Issue
Block a user