#!/usr/local/bin/zsh
# A notify-send-like wrapper to OSX's notify applescript thingie
#
# This is so I don't need a ton of OS-specific conditionals littering my
# dotfiles in order to work on OSX. This wrapper is NOT comprehensive and
# generally only covers the functionality actually used in my dotfiles.
#
# notify-send --hint=int:transient:1 -u %(urgency)s -i %(icon)s "%(safe_chan)s" "%(safe_msg)s"

local opts
# Consume and ignore all the notify-send flags.
zparseopts -E -D -a opts -- -hint: u: i:

title="${1:=Alert}"
message="${2:=Message}"

osascript -l JavaScript -e '
    var app = Application.currentApplication()
    app.includeStandardAdditions = true

    app.displayNotification("'"$message"'", {
        withTitle: "'"$title"'",
        soundName: "Frog"
    })
'
