-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
135 lines (117 loc) · 3.87 KB
/
install.ps1
File metadata and controls
135 lines (117 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# claude-code-ding installer for Windows
# Adds audio notification hooks to your Claude Code settings
# https://github.com/whoisjaso/claude-code-ding
$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host " claude-code-ding" -ForegroundColor Cyan
Write-Host " Audio notifications for Claude Code"
Write-Host " ─────────────────────────────────────"
Write-Host ""
Write-Host " Platform: Windows" -ForegroundColor Green
Write-Host ""
$settingsPath = Join-Path $env:USERPROFILE ".claude\settings.json"
$claudeDir = Join-Path $env:USERPROFILE ".claude"
# Ensure .claude directory exists
if (-not (Test-Path $claudeDir)) {
New-Item -ItemType Directory -Path $claudeDir -Force | Out-Null
}
# Load existing settings or create new
$settings = @{}
if (Test-Path $settingsPath) {
try {
$content = Get-Content $settingsPath -Raw
$settings = $content | ConvertFrom-Json -AsHashtable
} catch {
Write-Host " Error: Invalid JSON in $settingsPath" -ForegroundColor Red
Write-Host " Please fix your settings file and try again."
exit 1
}
}
# Ensure hooks object exists
if (-not $settings.ContainsKey("hooks")) {
$settings["hooks"] = @{}
}
$hooks = $settings["hooks"]
# Add PreToolUse for AskUserQuestion
if (-not $hooks.ContainsKey("PreToolUse")) {
$hooks["PreToolUse"] = @()
}
$hasAskHook = $false
foreach ($h in $hooks["PreToolUse"]) {
if ($h.matcher -eq "AskUserQuestion") { $hasAskHook = $true; break }
}
if (-not $hasAskHook) {
$hooks["PreToolUse"] += @{
matcher = "AskUserQuestion"
hooks = @(
@{
type = "command"
command = 'powershell -NoProfile -Command "[console]::beep(900,150); [console]::beep(1100,150); [console]::beep(900,150)"'
timeout = 5
async = $true
}
)
}
}
# Add Stop hook
if (-not $hooks.ContainsKey("Stop")) {
$hooks["Stop"] = @()
}
$hasStopHook = $false
foreach ($h in $hooks["Stop"]) {
foreach ($hh in $h.hooks) {
if ($hh.command -and $hh.command.Contains("beep")) { $hasStopHook = $true; break }
}
if ($hasStopHook) { break }
}
if (-not $hasStopHook) {
$hooks["Stop"] += @{
hooks = @(
@{
type = "command"
command = 'powershell -NoProfile -Command "[console]::beep(700,300); Start-Sleep -Milliseconds 100; [console]::beep(700,300)"'
timeout = 5
async = $true
}
)
}
}
# Add TaskCompleted hook
if (-not $hooks.ContainsKey("TaskCompleted")) {
$hooks["TaskCompleted"] = @()
}
$hasTaskHook = $false
foreach ($h in $hooks["TaskCompleted"]) {
foreach ($hh in $h.hooks) {
if ($hh.command -and $hh.command.Contains("beep")) { $hasTaskHook = $true; break }
}
if ($hasTaskHook) { break }
}
if (-not $hasTaskHook) {
$hooks["TaskCompleted"] += @{
hooks = @(
@{
type = "command"
command = 'powershell -NoProfile -Command "[console]::beep(600,150); [console]::beep(800,150); [console]::beep(1000,300)"'
timeout = 5
async = $true
}
)
}
}
# Write settings
$settings["hooks"] = $hooks
$json = $settings | ConvertTo-Json -Depth 10
$json | Set-Content $settingsPath -Encoding UTF8
Write-Host " Done! Hooks added to $settingsPath" -ForegroundColor Green
Write-Host ""
Write-Host " Three notification hooks installed:"
Write-Host " - Question asked -> attention beeps"
Write-Host " - Stopped / input -> ready signal"
Write-Host " - Task completed -> completion chime"
Write-Host ""
Write-Host " Restart Claude Code or open /hooks to activate."
Write-Host ""
Write-Host " Customize sounds: edit hooks in $settingsPath"
Write-Host " Uninstall: remove the hook entries from settings.json"
Write-Host ""