about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-03-04 20:01:19 +0000
committerJames Booth <boothj5@gmail.com>2014-03-04 20:01:19 +0000
commit8cfbb72337f76934002b8606fa715719cfe4d80c (patch)
treedfdddb389b2fba2c47fccd770ef1a9c600c5bc45 /src/ui
parenta9980621dccd0dde7af8510c0fc7c8f15d6d366c (diff)
downloadprofani-tty-8cfbb72337f76934002b8606fa715719cfe4d80c.tar.gz
Added OSX desktop notifications using terminal-notifier
Requires Xcode
WIP - No configure.ac changes
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/notifier.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index ebc61e0d..8582acf2 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include <glib.h>
 #ifdef HAVE_LIBNOTIFY
@@ -205,6 +206,25 @@ _notify(const char * const message, int timeout,
 
     Shell_NotifyIcon(NIM_MODIFY, &nid);
 #endif
+    GString *notify_command = g_string_new("terminal-notifier -title 'Profanity' -message '");
+    g_string_append(notify_command, message);
+    g_string_append(notify_command, "'");
+
+    char *term_name = getenv("TERM_PROGRAM");
+    char *app_id = NULL;
+    if (g_strcmp0(term_name, "Apple_Terminal") == 0) {
+        app_id = "com.apple.Terminal";
+    } else if (g_strcmp0(term_name, "iTerm.app") == 0) {
+        app_id = "com.googlecode.iterm2";
+    }
+
+    if (app_id != NULL) {
+        g_string_append(notify_command, " -sender ");
+        g_string_append(notify_command, app_id);
+    }
+
+    system(notify_command->str);
+    g_string_free(notify_command, TRUE);
 }
 
 void