DSH Authorization / Query Notification Plugin: Windows Toast + Notification Sound

Introduction

DSH pauses and waits when it needs your approval to perform an operation, answer a question, or approve a plan. When the window isn’t in the foreground, it’s easy to miss. dsh-alert is a DSH plugin that pops up a Windows system notification and plays a sound during these waiting periods, preventing tasks from stalling in the background unattended.

What Is This

  • Purpose: A DSH plugin that runs within the DSH host process and leverages native system capabilities to send notifications.
  • Maintainer: Chen HuaJing (Dvva).
  • Problem Solved: When DSH silently waits for authorization, answers, or plan approval, this plugin brings the user back with a system notification and sound.
  • Category: Client.
  • License: MIT.

Core Features

  • Dual-channel notification: Prefers native Windows WinRT Toast notifications; automatically falls back to a self-drawn card in the bottom-right corner on failure, ensuring nothing is missed.
  • Three session events:
  • approval/asked: DSH needs authorization for an operation.
  • tool/call = ask_user_question: DSH is waiting for an answer.
  • tool/call = exit_plan_mode: Plan approval.
  • Customizable sound: Uses a system WAV file by default; supports custom file paths or invoking an external player via playerCommand.
  • Fine-grained control: Independently toggle by trigger type and by channel (sound only / popup only / both).

Installation & Activation

Windows only. Requires the DSH desktop client (with Electron built in). The plugin runs inside the DSH host process, which allows it to send system notifications normally.

Step 1: Register a System Notification Identity (One-Time Only)

Windows 10 WinRT notifications require unpackaged applications to have an AUMID first; otherwise, you’ll get a 0x80073D54 no package identity error. Paste the following block into Windows PowerShell 5.1 (not pwsh 7) and execute:

$id  = 'Dsh.Alert'
$dir = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs'
$lnk = Join-Path $dir 'DSH Alert.lnk'

# 1) Start Menu placeholder shortcut (notification identity requires it to point to a real entry)
$ws = New-Object -ComObject WScript.Shell
$sc = $ws.CreateShortcut($lnk)
$sc.TargetPath = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
$sc.Arguments  = '-NoProfile -WindowStyle Hidden -Command "$null"'
$sc.Save()

# 2) Register AUMID
New-Item -Path "HKCU:\Software\Classes\AppUserModelId\$id" -Force | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Classes\AppUserModelId\$id" -Name DisplayName -Value 'DSH 提醒'
Set-ItemProperty -Path "HKCU:\Software\Classes\AppUserModelId\$id" -Name IconUri `
  -Value "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"

Step 2: Install into Your Profile

# Option A: dsh command (link install, keeps the source directory editable)
dsh plugin add --profile desktop link:<absolute-path-to-this-repo>

# Option B: Manual
# Copy the entire repo directory to %USERPROFILE%\.dsh\profiles\desktop\node_modules\dsh-alert
# Then append the following to the end of that profile's cordis.patch.yml:
#   - insert:
#       - id: dsh-alert
#         name: dsh-alert

Step 3: Restart DSH

The plugin is composed at startup and takes effect after a restart.

Configuration

Optional file: $DSH_HOME/.dsh-alert.json (defaults to %USERPROFILE%\.dsh\.dsh-alert.json). If not provided, all defaults are used.

{
  "enabled": true,
  "mode": "toast",
  "toast": true,
  "fallbackPopup": true,
  "sound": true,
  "durationMs": 6000,
  "triggers": { "approval": true, "question": true },
  "sounds": {
    "approval": "C:\\Windows\\Media\\Windows Exclamation.wav",
    "question": "C:\\Windows\\Media\\Windows Notify.wav"
  },
  "playerCommand": "",
  "minIntervalMs": 3000
}
Field Description
enabled Master switch
mode toast (system notification, auto-falls back to card on failure) / popup (bottom-right card only) / sound (sound only)
toast Whether to attempt system notification
fallbackPopup Whether to show a card when Toast fails
sound Whether to play a notification sound
durationMs Card display duration (milliseconds)
triggers.approval Whether to alert on authorization requests
triggers.question Whether to alert on questions / plan approvals
sounds.approval / sounds.question WAV file paths for notification sounds
playerCommand Use an external player; %file% is the placeholder, e.g. ffplay -nodisp -autoexit "%file%"
minIntervalMs Minimum interval between two alerts to prevent spam (default 3000)

How It Works

DSH Session Events
   ├─ approval/asked            ─┐
   ├─ tool/call(ask_user_question)├─→ Throttle → Play Sound → WinRT Toast
   └─ tool/call(exit_plan_mode)  ─┘              └─ Failure → Bottom-right card
  • Notifications are sent via WinRT by powershell.exe (5.1) invoked from the host process (DSH main process);
  • Processes inside the sandbox cannot send system notifications (restricted token), so the plugin runs on the host side;
  • All failure paths fall back to the self-drawn card — no silent failures.

Compatibility

Item Requirement
OS Windows 10 / 11
DSH Desktop client (Electron, host process)
PowerShell System-bundled 5.1 (pwsh 7 lacks WinRT references; the plugin hardcodes the 5.1 path)
Node ≥20 (development/debugging only)

FAQ

No notification / no sound?
1. Make sure Settings → System → Notifications isn’t disabled, and “Focus assist” is not active;
2. Verify that the AUMID from Step 1 is registered (registry key HKCU\Software\Classes\AppUserModelId\Dsh.Alert exists);
3. Temporarily set mode to popup to rule out Toast channel issues;
4. Check whether the minIntervalMs throttle is being hit.

I want to use my own sound file.
Fill in the WAV path in sounds.approval / sounds.question, or use playerCommand to invoke an external player.

Will it pop up repeatedly?
The same trigger type only fires once within the minIntervalMs window.

Use Cases & Cautions

Ideal for scenarios where DSH runs long-term and you want to avoid missing authorization requests, questions, or plan approvals because the window isn’t in the foreground.

Important: The plugin runs with the same privileges as the current DSH process. Review the source code and license before installing.

Conclusion

Through its dual-channel mechanism of native Toast + notification sound, dsh-alert turns DSH’s waiting periods from “silent” to “perceivable,” reducing the risk of tasks stalling in the background. For more details and source code, visit the plugin directory page or the GitHub repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye