fix(hooks): use terminal-notifier for macOS notification click-to-focus
This commit is contained in:
parent
f3cbc24e78
commit
1c6d384f14
@ -7,6 +7,7 @@ import {
|
||||
getAfplayPath,
|
||||
getPaplayPath,
|
||||
getAplayPath,
|
||||
getTerminalNotifierPath,
|
||||
} from "./session-notification-utils"
|
||||
import { buildWindowsToastScript, escapeAppleScriptText, escapePowerShellSingleQuotedText } from "./session-notification-formatting"
|
||||
|
||||
@ -39,6 +40,19 @@ export async function sendSessionNotification(
|
||||
): Promise<void> {
|
||||
switch (platform) {
|
||||
case "darwin": {
|
||||
// Try terminal-notifier first — deterministic click-to-focus
|
||||
const terminalNotifierPath = await getTerminalNotifierPath()
|
||||
if (terminalNotifierPath) {
|
||||
const bundleId = process.env.__CFBundleIdentifier
|
||||
const args = [terminalNotifierPath, "-title", title, "-message", message]
|
||||
if (bundleId) {
|
||||
args.push("-activate", bundleId)
|
||||
}
|
||||
await ctx.$`${args}`.catch(() => {})
|
||||
break
|
||||
}
|
||||
|
||||
// Fallback: osascript (click may open Finder instead of terminal)
|
||||
const osascriptPath = await getOsascriptPath()
|
||||
if (!osascriptPath) return
|
||||
|
||||
|
||||
@ -32,11 +32,13 @@ export const getPowershellPath = createCommandFinder("powershell")
|
||||
export const getAfplayPath = createCommandFinder("afplay")
|
||||
export const getPaplayPath = createCommandFinder("paplay")
|
||||
export const getAplayPath = createCommandFinder("aplay")
|
||||
export const getTerminalNotifierPath = createCommandFinder("terminal-notifier")
|
||||
|
||||
export function startBackgroundCheck(platform: Platform): void {
|
||||
if (platform === "darwin") {
|
||||
getOsascriptPath().catch(() => {})
|
||||
getAfplayPath().catch(() => {})
|
||||
getTerminalNotifierPath().catch(() => {})
|
||||
} else if (platform === "linux") {
|
||||
getNotifySendPath().catch(() => {})
|
||||
getPaplayPath().catch(() => {})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user