2b2d6d746ca3ed6dfac26be331e49fa80a1191ab

Author
Denys Dovhan <denysdovhan@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(bgnotify): use lsappinfo, add support for ghostty (#13314)

Diff

 1diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
 2index dca8250bec939ccf3e838cf553513e259dbc4150..4c1613eed175995590e1126ba71bfaedc9553d26 100644
 3--- a/plugins/bgnotify/bgnotify.plugin.zsh
 4+++ b/plugins/bgnotify/bgnotify.plugin.zsh
 5@@ -60,8 +60,10 @@ function bgnotify_formatted {
 6 }
 7 
 8 function bgnotify_appid {
 9-  if (( ${+commands[osascript]} )); then
10-    osascript -e "tell application id \"$(bgnotify_programid)\"  to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
11+  if (( ${+commands[lsappinfo]} )); then
12+    lsappinfo info -only bundleid "$(lsappinfo front)" | awk -F= '{print $2}' | tr -d '"' 2>/dev/null
13+  elif (( ${+commands[osascript]} )); then
14+    osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
15   elif [[ -n $WAYLAND_DISPLAY ]] && ([[ -n $SWAYSOCK ]] || [[ -n $I3SOCK ]]) && (( ${+commands[swaymsg]} )); then # wayland+sway
16     local app_id=$(bgnotify_find_sway_appid)
17     [[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS
18@@ -108,6 +110,7 @@ function bgnotify_programid {
19   case "$TERM_PROGRAM" in
20     iTerm.app) echo 'com.googlecode.iterm2' ;;
21     Apple_Terminal) echo 'com.apple.terminal' ;;
22+    ghostty) echo 'com.mitchellh.ghostty' ;;
23   esac
24 }
25