11# Report macOS notification counts for given app ids (banner notifications only)
22# Based on http://www.ign.com/boards/threads/a-crumby-way-to-get-an-unread-count-of-imessages-into-applescript.453061379/
33
4- TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS_DEFAULT=" 5"
4+ # 118 = messages
5+ # 51 = slack
6+
7+ TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS_DEFAULT=" 118"
58TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_CHAR_DEFAULT=" 💬"
69
710generate_segmentrc () {
811 read -d ' ' rccontents << EORC
912# App ids to query in notification center, separated by space
1013# To get the app id that is associated with a specific app run:
11- # sqlite3 -list "$( getconf DARWIN_USER_DIR) /com.apple.notificationcenter/db /db" 'select * from app_info '
14+ # sqlite3 -list "$( getconf DARWIN_USER_DIR) /com.apple.notificationcenter/db2 /db" 'select * from app '
1215# The first column contains the app ids
13- # "5" is the app id of Messages.app
16+ # The last column contains the message count
17+ # "118" is the app id of Messages.app
1418# Only "banner" notifications are supported (see settings in the notification center)
1519export TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS="${TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS_DEFAULT} "
1620# Notification symbol
@@ -32,13 +36,13 @@ run_segment() {
3236 __process_settings
3337
3438 local db_location app_ids_array query_condition query_string count
35- db_location=" $( getconf DARWIN_USER_DIR) /com.apple.notificationcenter/db /db"
39+ db_location=" $( getconf DARWIN_USER_DIR) /com.apple.notificationcenter/db2 /db"
3640 app_ids_array=(${TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS} )
3741 query_condition=" where app_id=${app_ids_array[0]} "
3842 for app_id in " ${app_ids_array[@]: 1} " ; do
3943 query_condition=" ${query_condition} OR app_id=${app_id} "
4044 done
41- query_string=" select count(* ) from notifications ${query_condition} "
45+ query_string=" select sum(badge ) from app ${query_condition} "
4246 count=$( sqlite3 -list ${db_location} " ${query_string} " )
4347
4448 local exitcode=" $? "
0 commit comments