about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-03-05 00:11:50 +0000
committerJames Booth <boothj5@gmail.com>2014-03-05 00:11:50 +0000
commitd68c5941503e7bbc1a6dbaf56a5ad83d1c9ba744 (patch)
tree58ce397a861946f0a8f3c4075a7f509a7e9dcd7b /src
parent4d00f788e90d5b0b76a51f21e2d8d87675046066 (diff)
parentb5171cb054c9d9f4efb2ddb69c41a922b14f0aab (diff)
downloadprofani-tty-d68c5941503e7bbc1a6dbaf56a5ad83d1c9ba744.tar.gz
Merge branch 'osx-notify'
Diffstat (limited to 'src')
-rw-r--r--src/ui/notifier.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index ebc61e0d..16fd814f 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,31 @@ _notify(const char * const message, int timeout,
 
     Shell_NotifyIcon(NIM_MODIFY, &nid);
 #endif
+#ifdef HAVE_OSXNOTIFY
+    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);
+    }
+
+    int res = system(notify_command->str);
+    if (res == -1) {
+        log_error("Could not send desktop notificaion.");
+    }
+
+    g_string_free(notify_command, TRUE);
+#endif
 }
 
 void