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,
|
getAfplayPath,
|
||||||
getPaplayPath,
|
getPaplayPath,
|
||||||
getAplayPath,
|
getAplayPath,
|
||||||
|
getTerminalNotifierPath,
|
||||||
} from "./session-notification-utils"
|
} from "./session-notification-utils"
|
||||||
import { buildWindowsToastScript, escapeAppleScriptText, escapePowerShellSingleQuotedText } from "./session-notification-formatting"
|
import { buildWindowsToastScript, escapeAppleScriptText, escapePowerShellSingleQuotedText } from "./session-notification-formatting"
|
||||||
|
|
||||||
@ -39,6 +40,19 @@ export async function sendSessionNotification(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case "darwin": {
|
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()
|
const osascriptPath = await getOsascriptPath()
|
||||||
if (!osascriptPath) return
|
if (!osascriptPath) return
|
||||||
|
|
||||||
|
|||||||
@ -32,11 +32,13 @@ export const getPowershellPath = createCommandFinder("powershell")
|
|||||||
export const getAfplayPath = createCommandFinder("afplay")
|
export const getAfplayPath = createCommandFinder("afplay")
|
||||||
export const getPaplayPath = createCommandFinder("paplay")
|
export const getPaplayPath = createCommandFinder("paplay")
|
||||||
export const getAplayPath = createCommandFinder("aplay")
|
export const getAplayPath = createCommandFinder("aplay")
|
||||||
|
export const getTerminalNotifierPath = createCommandFinder("terminal-notifier")
|
||||||
|
|
||||||
export function startBackgroundCheck(platform: Platform): void {
|
export function startBackgroundCheck(platform: Platform): void {
|
||||||
if (platform === "darwin") {
|
if (platform === "darwin") {
|
||||||
getOsascriptPath().catch(() => {})
|
getOsascriptPath().catch(() => {})
|
||||||
getAfplayPath().catch(() => {})
|
getAfplayPath().catch(() => {})
|
||||||
|
getTerminalNotifierPath().catch(() => {})
|
||||||
} else if (platform === "linux") {
|
} else if (platform === "linux") {
|
||||||
getNotifySendPath().catch(() => {})
|
getNotifySendPath().catch(() => {})
|
||||||
getPaplayPath().catch(() => {})
|
getPaplayPath().catch(() => {})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user