From 4a9e4b8e03f4b05a6d209b67c7af8ba233cef2f8 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Thu, 1 Aug 2019 11:23:33 +0300 Subject: [PATCH 1/4] Improve notifications on macOS --- auto-notify.plugin.zsh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 80aad5d..f85da8c 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -42,10 +42,11 @@ function _auto_notify_message() { fi notify-send "$title" "$body" "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME" elif [[ "$platform" == "Darwin" ]]; then - # We need to escape quotes since we are passing a script into a command - body="${body//\"/\\\"}" - title="${title//\"/\\\"}" - osascript -e "display notification \"$body\" with title \"$title\"" + osascript \ + -e 'on run argv' \ + -e 'display notification (item 1 of argv) with title (item 2 of argv)' \ + -e 'end run' \ + "$body" "$title" else printf "Unknown platform for sending notifications: $platform\n" printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n" From 73da2d107e97bed9a5598d95ea65b768231f427d Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Thu, 1 Aug 2019 11:39:33 +0300 Subject: [PATCH 2/4] Fix tests --- tests/test_auto_notify_send.zunit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_auto_notify_send.zunit b/tests/test_auto_notify_send.zunit index 2e0bb2c..baee452 100644 --- a/tests/test_auto_notify_send.zunit +++ b/tests/test_auto_notify_send.zunit @@ -108,8 +108,8 @@ run _auto_notify_send assert $state equals 0 - assert "$lines[1]" same_as '-e display notification "Total time: 20 seconds' - assert "$lines[2]" same_as 'Exit code: 0" with title "\"f bar -r\" Completed"' + assert "$lines[1]" same_as '-e on run argv -e display notification (item 1 of argv) with title (item 2 of argv) -e end run Total time: 20 seconds' + assert "$lines[2]" same_as 'Exit code: 0 "f bar -r" Completed' } @test 'auto-notify-send sends warning on unsupported platform' { From bada173f1047fb233d614f73d52e3813ca03144e Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Thu, 1 Aug 2019 11:40:17 +0300 Subject: [PATCH 3/4] Change MacOSX to macOS --- tests/test_auto_notify_send.zunit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_auto_notify_send.zunit b/tests/test_auto_notify_send.zunit index baee452..644fd7b 100644 --- a/tests/test_auto_notify_send.zunit +++ b/tests/test_auto_notify_send.zunit @@ -92,7 +92,7 @@ assert "$lines[4]" same_as "--urgency=normal --expire-time=15000" } -@test 'auto-notify-send sends notification on MacOSX' { +@test 'auto-notify-send sends notification on macOS' { AUTO_COMMAND="f bar -r" AUTO_COMMAND_FULL="foo bar -r" AUTO_COMMAND_START=11080 From c029e8e4c13d6d702dcee2dfb0d39aa0d9353c46 Mon Sep 17 00:00:00 2001 From: Michael Aquilina Date: Thu, 1 Aug 2019 13:40:03 +0100 Subject: [PATCH 4/4] Bump to version 0.5.1 --- CHANGELOG.md | 4 ++++ auto-notify.plugin.zsh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bacfea..3e5c070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog for zsh-auto-notify ============================= +0.5.1 +----- +* Improved handling of MacOS notifications via #16 (Thanks @dmitmel!) + 0.5.0 ----- * Support changing notification title and body using AUTO_NOTIFY_TITLE and AUTO_NOTIFY_BODY diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index f85da8c..525d8a3 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -1,4 +1,4 @@ -export AUTO_NOTIFY_VERSION="0.5.0" +export AUTO_NOTIFY_VERSION="0.5.1" # Time it takes for a notification to expire export AUTO_NOTIFY_EXPIRE_TIME=8000