← Catalog

@ethantang1024/pi-notify

Focus-aware desktop notifications and sounds for Pi coding agent. Fires on task completion, errors, and questions with DECSET 1004 terminal focus tracking and 100% reliable native OS delivery (Windows Shell NotifyIcon, Linux libnotify).

Extension

Install

Install with PiG

pig install npm:@ethantang1024/pi-notify

Install with Pi

pi install npm:@ethantang1024/pi-notify
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/index.js"
  ]
}

README

Written by the package's publisher, shown as published in version 1.0.1 (README.md). PiG does not review it.

@ethantang1024/pi-notify

English | 简体中文

Focus-Aware Desktop Notifications and Sounds for the Pi Coding Agent.
Seamlessly blends DECSET 1004 terminal focus tracking with 100% reliable native OS delivery (Windows Shell Tray BalloonTip, Linux D-Bus notify-send, and macOS osascript).


🌟 Key Features & Problem Solved

  1. Focus-Aware Quiet Mode:
    • While actively working in terminal: When your eyes are on the screen coding or asking single-turn questions, it stays 100% silent—zero annoying toasts or sounds!
    • When switching away: Once you switch to a browser, editor, or documentation window, it immediately alerts you when long runs complete, errors occur, or when input is required.
  2. 100% Deterministic Native OS Delivery (No Swallowed OSC Sequences):
    • Windows 11: Directly invokes Win32 Shell System.Windows.Forms.NotifyIcon (balloon tip) and [console]::beep via PowerShell, completely bypassing fragile terminal escape sequences. Works 100% in Windows Terminal and WezTerm!
    • Linux (Standard Distributions & NixOS): Communicates via the Freedesktop notify-send D-Bus notification protocol, backed by multi-tiered audio drivers (PulseAudio paplay, PipeWire pw-play, and ALSA aplay);
    • macOS: Built-in support for osascript notification center and afplay;
    • Headless / SSH Remote Sessions: Automatically degrades to OSC 777 / OSC 99 terminal escape sequences and ASCII bell \x07.
  3. Comprehensive Lifecycle Tracking:
    • Task Completion (agent_settled): Notifies on run finish when away;
    • Errors (tool_result isError): High-priority alerts on unexpected exceptions;
    • User Input Needed (ui_prompt_start): Alerts when Pi blocks on a question or confirmation prompt, preventing idle lockups.

🐧 Cross-Platform & Linux Compatibility Matrix

1. Operating System & Desktop Environment Matrix

OS / DistributionDesktop / Window ManagerPrerequisite Install CommandNotification Daemon / APIAudio Cascade (4 Tiers)Delivery Status
Windows 10 / 11Windows ShellNone (built-in PowerShell)Win32 NotifyIcon BalloonTip[console]::beep✅ 100% Native
Ubuntu / Debian / MintGNOME / XFCE / MATEapt install -y libnotify-bin pulseaudio-utilsGNOME Shell / xfce4-notifydpaplay → pw-play → aplay → Bell✅ 100% Native
Fedora / RHEL / CentOSGNOME / KDE Plasmadnf install -y libnotify pulseaudio-utilsGNOME Shell / knotifypw-play → paplay → aplay → Bell✅ 100% Native
Arch / ManjaroKDE / Hyprland / Swaypacman -S libnotify libpulseknotify / dunst / makopw-play → paplay → aplay → Bell✅ 100% Native
openSUSE (Tumbleweed/Leap)KDE Plasma / GNOMEzypper install -y libnotify-tools pulseaudio-utilsPlasma / GNOMEpw-play → paplay → aplay → Bell✅ 100% Native
NixOSNiri / Noctalia / GNOMEpkgs.libnotify, pkgs.pulseaudioNoctalia / GNOME / makoPipeWire / paplay✅ 100% Native
Alpine LinuxSway / Minimalapk add libnotify pulseaudio-utilsmako / fnottALSA / paplay✅ 100% Native
macOSAqua DesktopNone (built-in)osascript Notification Centerafplay native audio✅ 100% Native
Headless / SSH RemotePure CLI TerminalNone requiredDegrades to OSC 777 / OSC 99Terminal Bell (\x07)🔄 Remote Pass-through

2. Terminal Emulators & Focus Sensing (DECSET 1004) Matrix

Terminal EmulatorDECSET 1004 Focus TrackingRemote Pass-through (WSL2 / SSH)Notification ProtocolConfiguration Notes & Fallback
WezTerm✅ Full Support (\x1b[I / \x1b[O)✅ Full Pass-throughWin32 Toast / notify-send / OSC 9Works out-of-the-box, sensitive focus tracking
Windows Terminal✅ Full Support (1.16+)✅ Full Pass-throughWin32 Shell Tray BalloonTipWorks out-of-the-box, passes through WSL2 PTY
Kitty✅ Full Support✅ Full Pass-throughLinux notify-send / OSC 99Works out-of-the-box
Ghostty✅ Full Support✅ Full Pass-throughOS Native / OSC 9 / OSC 777Works out-of-the-box
Foot (Wayland)✅ Full Support✅ Full Pass-throughLinux notify-sendUltra-fast Wayland terminal, out-of-the-box
GNOME Terminal / Ptyxis / Tilix✅ Full Support (VTE 0.40+)✅ Full Pass-throughLinux notify-sendDefault terminal across major distributions
Tmux (Multiplexer)⚡ Config Required✅ Full Pass-throughInherits active client focusRequires set -g focus-events on in ~/.tmux.conf
Alacritty⚠️ Graceful Fallback⚠️ Graceful FallbackOS Native NotificationFalls back to away duration heuristics safely

[!TIP]

  1. Standalone Window Managers (i3 / Sway / Hyprland): Ensure a notification daemon (e.g. dunst &, mako &, or swaync &) is running in your session.
  2. Tmux Users: Append set -g focus-events on to ~/.tmux.conf so terminal focus events pass through cleanly.

⚙️ Installation & Configuration

1. Installation

Run the following command in any terminal:

pi install https://github.com/ethantang1024/pi-notify.git

2. Configuration (settings.json)

Configure "notify" in your ~/.pi/agent/settings.json (or .pi/settings.json for project scope):

{
  "packages": [
    "npm:gentle-engram@0.5.1",
    "https://github.com/ethantang1024/pi-notify.git"
  ],
  "notify": {
    "focusAware": true,
    "onComplete": true,
    "onError": true,
    "onQuestion": true,
    "sound": false,
    "volume": 0.4,
    "minWorkMs": 2000,
    "minAwayMs": 1000,
    "alwaysNotifyOnError": true
  }
}

3. Configuration Reference

OptionTypeDefaultDescription
focusAwarebooleantrueEnables terminal focus awareness. When active, keeps notifications quiet while you are focused on the terminal.
onCompletebooleantrueNotify on task completion (only triggers when unfocused if focusAware is enabled).
onErrorbooleantrueNotify on command or tool errors.
onQuestionbooleantrueNotify when agent pauses waiting for user input (triggers only when unfocused).
soundbooleanfalseWhether to play sound alerts.
volumenumber0.4Volume level between 0.0 and 1.0 (Linux sound drivers).
minWorkMsnumber2000Minimum task duration in ms before qualifying for completion notifications (ignores instant turns).
minAwayMsnumber1000Minimum unfocused duration in ms before firing (prevents accidental switch triggers).
alwaysNotifyOnErrorbooleantrueAlways trigger notification on error, even if focused.

🛠️ Diagnostics & Commands

  • /notify or /notify check: Prints current focus state, detected backend, and active settings in Pi's status bar:
    Backend: linux | Focus: FOCUSED (quiet mode) (away: n/a) | focusAware: true | sound: false
    
  • /notify test: Instantly dispatches a test notification and plays an alert sound to verify end-to-end functionality.

📄 License

MIT License. See LICENSE for details.