Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roeniss
Copy link

@roeniss roeniss commented Mar 17, 2024

Hi, this is my first issue to zsh-auto-notify. I hope you liked this.

  • Add zunit tests
  • Add docs
  • Tested with Ubuntu 22.04 and macOS 14.2

@roeniss
Copy link
Author

roeniss commented Mar 17, 2024

@MichaelAquilina
please give me some feedback when available :)

@V4G4X
Copy link

V4G4X commented Mar 18, 2024

Pretty cool!

I tested it and it worked.

Comment on lines 65 to 77
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
Copy link

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?

Suggested change
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[@]}

Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sound support
2 participants