1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

macOS Sequoia でosascript通知が動かない問題の解決法

Posted at

macOS Sequoia でosascript通知が動かない問題の解決法

問題の概要

Claude Codeのhooksで通知をさせようとして、webやClaudeで調べて以下のosascriptコマンドを見つけました:

osascript -e 'display notification "Claude Codeが許可を求めています" with title "Claude Code" subtitle "確認待ち" sound name "Glass"'

しかし、macOS 15.6 (Sequoia) では通知が表示されませんでした。

原因の調査

基本的な切り分け

まず基本的な動作確認を行いました:

# AppleScript自体の動作確認
osascript -e 'display dialog "テスト"'  # → 正常に動作

# シンプルな通知
osascript -e 'display notification "test"'  # → 動作せず

AppleScript自体は動作するが、通知機能のみが動作しないことが判明しました。

システムログの確認

NotificationCenterのログを確認:

log stream --predicate 'process == "NotificationCenter"' --info

重要な部分:

NotificationCenter: [com.apple.unc:application] Ignoring ... from com.apple.ScriptEditor2, not visible
notificationsAllowed: false

発見事項:

  • 通知は com.apple.ScriptEditor2(スクリプトエディタ)から送信されている
  • notificationsAllowed: false となっており、通知が許可されていない

解決方法

macOS Sequoiaでの新しい権限システム

macOS Sequoiaでは、osascriptコマンドが内部的にスクリプトエディタを使用するため、スクリプトエディタの通知権限が必要になりました。

具体的な解決手順

  1. スクリプトエディタを起動
open -a "Script Editor"
  1. スクリプトエディタ内で通知を実行

    • 新しいドキュメントを作成
    • 以下のコードを入力:
    display notification "テスト" with title "Claude Code"
    
    • 実行ボタン(▶️)をクリック
  2. 権限ダイアログで許可

    • 通知権限のダイアログが表示される
    • 「許可」をクリック
  3. システム設定で確認

    • システム設定 > 通知
    • スクリプトエディタ が追加されていることを確認
    • 必要に応じて設定を調整

技術的な背景

なぜこの問題が発生するのか

  • macOS Sequoiaではセキュリティが強化された
  • osascriptコマンドは内部的にスクリプトエディタを使用
  • アプリケーションごとの通知権限が厳格に管理されるようになった
  • 初回実行時に明示的な権限付与が必要

webで見つけたコマンドとSequoiaでの動作

項目 一般的なwebの情報 macOS Sequoia
osascript通知 そのまま動作するとされる スクリプトエディタの権限が必要
権限設定 言及されていないことが多い 必須
初回実行 動作するとされる 権限ダイアログが必要

トラブルシューティングのポイント

効果的な切り分け方法

  1. 基本動作の確認

    osascript -e 'display dialog "テスト"'
    
  2. システムログの活用

    log stream --predicate 'process == "NotificationCenter"' --info
    
  3. 段階的なテスト

    • シンプルな通知から始める
    • 徐々に要素を追加して問題箇所を特定

よくある見落とし

  • 集中モード(おやすみモード) の確認
  • 通知設定 でのアプリ別権限
  • 内部的なアプリ名 の理解(osascript = スクリプトエディタ)

まとめ

webで見つけたosascriptコマンドをそのまま使ってもmacOS Sequoiaでは動作しません。この問題は:

  • webの情報だけでは不十分 なケースの典型例

  • 一度設定すれば恒久的 に動作する

  • 他の類似問題 でも同様のアプローチが有効

参考情報

  • macOS バージョン: 15.6 (Sequoia)
  • 影響するコマンド: osascript での display notification
  • 必要な権限: スクリプトエディタの通知権限
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?