-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AUTO_NOTIFY_SOUND
env var to provide sound option
#55
base: master
Are you sure you want to change the base?
Conversation
@MichaelAquilina |
Pretty cool! I tested it and it worked. |
auto-notify.plugin.zsh
Outdated
if [[ -z "$AUTO_NOTIFY_SOUND" ]]; then | ||
osascript \ | ||
-e 'on run argv' \ | ||
-e 'display notification (item 1 of argv) with title (item 2 of argv)' \ | ||
-e 'end run' \ | ||
"$body" "$title" | ||
else | ||
osascript \ | ||
-e 'on run argv' \ | ||
-e 'display notification (item 1 of argv) with title (item 2 of argv) sound name (item 3 of argv)' \ | ||
-e 'end run' \ | ||
"$body" "$title" "$AUTO_NOTIFY_SOUND" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too well-versed with shell scripting.
But is it possible to extract the common command line arguments here out?
Something like?
if [[ -z "$AUTO_NOTIFY_SOUND" ]]; then | |
osascript \ | |
-e 'on run argv' \ | |
-e 'display notification (item 1 of argv) with title (item 2 of argv)' \ | |
-e 'end run' \ | |
"$body" "$title" | |
else | |
osascript \ | |
-e 'on run argv' \ | |
-e 'display notification (item 1 of argv) with title (item 2 of argv) sound name (item 3 of argv)' \ | |
-e 'end run' \ | |
"$body" "$title" "$AUTO_NOTIFY_SOUND" | |
fi | |
notification_body := "$body" "$title" | |
if [[ ! -z "$AUTO_NOTIFY_SOUND" ]]; then | |
notification_body += ("$AUTO_NOTIFY_SOUND") | |
else | |
osascript \ | |
-e 'on run argv' \ | |
-e 'display notification (item 1 of argv) with title (item 2 of argv) sound name (item 3 of argv)' \ (OPTIONAL CONCAT HERE AS WELL) | |
-e 'end run' \ | |
${notification_body[@]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for suggestion. I'm not sure if i get it right but made changes. Check it out please!
Hi, this is my first issue to zsh-auto-notify. I hope you liked this.