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

Specify the sound for a specific notification #17

Closed
variadico opened this issue Feb 6, 2016 · 5 comments
Closed

Specify the sound for a specific notification #17

variadico opened this issue Feb 6, 2016 · 5 comments
Milestone

Comments

@variadico
Copy link
Owner

After playing with v2.0.0 for a bit, I was curious, how easy would it be to bring back the -s tag for sounds rather than speech? I like the speech option but it is much more beneficial to me to be able to specify the sound for a specific notification.

For example, I'm using noti to notify me when build/deployments are complete or have failed. It was nice being able to specify the "Hero" sound for the error notification so I could easily tell the difference. The only option I have at the moment is to set a system variable before and after the noti call, which is not ideal.

@KingKrimmson

@variadico
Copy link
Owner Author

To set the sound for a notification like the old -s, you have two options:

  1. Set the default sound to Hero with export NOTI_SOUND=hero once.
  2. Use hero for only 1 run with NOTI_SOUND=hero noti foo.

However, did you also mean you wanted a different sound when a process succeeds vs fails?

For example:

if process succeeds
  play Hero
else if process fails
  play Ping

@KingKrimmson
Copy link

However, did you also mean you wanted a different sound when a process succeeds vs fails?

Yes, in my aliases, I have something like:
run_script="~/scripts/my_script.sh && noti -t $PSNAME -m 'Success' || noti -s Hero -t $PSNAME -m 'Failure'"
That way there is a clearly different sound for each. Perhaps if I use your second option like:
run_script="~/scripts/my_script.sh && noti -t $PSNAME -m 'Success' || NOTI_SOUND=Hero noti -t $PSNAME -m 'Failure'"
I can get my preferred functionality. My assumption was after this run, the system variable would then be set to Hero, making all other noti's set to Hero as well, but I never got around to testing it.

@variadico
Copy link
Owner Author

Ah, okay. I actually liked having two different sounds for the notifications as well. With the refactor, I accidentally removed the ability to do that.

What do you think about these changes?

Basically you can simplify the commands like this.

export NOTI_SOUND=Ping
export NOTI_SOUND_FAIL=Hero
# Or define that in your .zshrc file to make this permanent.

run_script="~/scripts/my_script.sh && noti -t $PSNAME -m 'Success' || noti -t $PSNAME -m 'Failure'"

# Or maybe even just
run_script="noti ~/scripts/my_script.sh"
# If my_script.sh fails, the title will automatically be "my_script.sh failed" and 
# the message "exit status 1".

@KingKrimmson
Copy link

That's perfect. Creates exactly the functionality I need and still allows users to set default sounds, I like it.

@variadico variadico modified the milestone: v2.1.0 Feb 18, 2016
@variadico
Copy link
Owner Author

Closing issue because this has been implemented on dev. Though, it won't be officially released until v2.1.0.

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

No branches or pull requests

2 participants