Add support for MacOSX

This commit is contained in:
Michael Aquilina 2019-07-15 10:08:15 +01:00
parent 4d15a4cd21
commit eecf71b040
No known key found for this signature in database
GPG key ID: 636066730B056BD1

View file

@ -18,7 +18,14 @@ function _auto_notify_message() {
local command="$1" local command="$1"
local elapsed="$2" local elapsed="$2"
# Run using echo -e in order to make sure notify-send picks up new line # Run using echo -e in order to make sure notify-send picks up new line
echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)" text="$(echo -e "\"$command\" has completed\n(Total time: $elapsed seconds)")"
platform="$(uname)"
if [[ "$platform" = "Linux" ]]; then
notify-send "$text"
elif [[ "$platform" == "Darwin" ]]; then
display notification "$text" with title "Command Completed"
fi
} }
function _is_auto_notify_ignored() { function _is_auto_notify_ignored() {
@ -42,7 +49,7 @@ function _auto_notify_send() {
let "elapsed = current - AUTO_COMMAND_START" let "elapsed = current - AUTO_COMMAND_START"
if [[ -n "$AUTO_COMMAND" && $elapsed -gt $AUTO_NOTIFY_THRESHOLD ]]; then if [[ -n "$AUTO_COMMAND" && $elapsed -gt $AUTO_NOTIFY_THRESHOLD ]]; then
notify-send "$(_auto_notify_message "$AUTO_COMMAND" "$elapsed")" _auto_notify_message "$AUTO_COMMAND" "$elapsed"
fi fi
} }