8000 Add require_interaction option to make notification sticky. by brenns10 · Pull Request #10 · ShopRunner/jupyter-notify · GitHub
[go: up one dir, main page]

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 require_interaction option to make notification sticky. #10

Merged
merged 3 commits into from
Aug 18, 2017
Merged

Add require_interaction option to make notification sticky. #10

merged 3 commits into from
Aug 18, 2017

Conversation

brenns10
Copy link
Contributor

I have multiple monitors and don't immediately notice when a notification pops up. So, this adds the ability to make notifications "sticky", i.e. they won't go away until the user dismisses them manually. Default behavior remains the same -- the user has to manually enable this functionality. See README changes for documentation on how to enable it.

I was hoping to get notification sounds to work as well, but it appears that no browsers support it yet. Plus, I would have to figure out a place to stick a static sound file for jupyter to serve as the notification sound.

@mdagost
Copy link
Contributor
mdagost commented Aug 17, 2017

Thanks for the pull request! I'll take a look as soon as I can. In the meantime, I'm pretty certain that I heard notification sounds when I tested in Firefox. There's a link in the README to this page, which suggests you can turn them on and off in the OS X settings:

https://stackoverflow.com/questions/27491672/disable-default-alert-sound-for-firefox-web-notifications

@brenns10
Copy link
Contributor Author

Thank you! I saw that in the readme, but I'm using Chrome and was hoping to avoid running a second browser. It seems that the Firefox behavior is just an implementation inconsistency.

@mdagost
Copy link
Contributor
mdagost commented Aug 18, 2017

@brenns10 Thanks again for the PR. This is a great option, and the code works for me as specified in both 2.7 and 3. How would you feel about calling the option require_dismissal rather than require_interaction?

@brenns10
Copy link
Contributor Author

Hey @mdagost! The name doesn't matter to me. I chose it to match the option requireInteraction from the Notification API. If you would prefer require_dismissal, I would be happy to swap it real quick.

Copy link
Contributor
@parsing-science parsing-science left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brenns10: This seems like a great addition! I found a couple of minor things to change.

@mdagost asked my opinion on the variable name. I think requires_interaction makes sense since clicking on settings or close removes the notification, not just dismissal. @mdagost: what do you think?

README.md Outdated
```python
import jupyternotify
ip = get_ipython()
ip.register_magics(jupyternotify.JupyterNotifyMagics(ip,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put ip on its own line?

ip.register_magics(jupyternotify.JupyterNotifyMagics(
    ip,
    option_name="option_value"
))

README.md Outdated

The following options exist:
- `require_interaction` - Boolean, default False. When this is true,
notifications will remain on screen untill dismissed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: untill should be until.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, looks like this will only work in Chrome. Could you just add a note in the doc for this option to that effect?

super(JupyterNotifyMagics, self).__init__(shell)
with open(resource_filename("jupyternotify", "js/init.js")) as jsFile:
jsString = jsFile.read()
display(Javascript(jsString))
self.options = json.dumps({
'requireInteraction': require_interaction,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change these single quotes to double quotes so the file is consistent?

@mdagost
Copy link
Contributor
mdagost commented Aug 18, 2017

Yep--agree. Let's leave it as require_interaction. I'm testing on Firefox at the moment but seem to have messed up my setup...

@mdagost
Copy link
Contributor
mdagost commented Aug 18, 2017

Yeah, confirmed that this only works in Chrome at the moment. That's what the API docs suggest too.

@brenns10
Copy link
Contributor Author

@parsing-science: I've made all the changes you requested!

@brenns10
Copy link
Contributor Author

Except the note about Chrome. One more commit incoming!

@mdagost
Copy link
Contributor
mdagost commented Aug 18, 2017

Thanks @brenns10 ! I'll merge this now and push a new version to PyPI.

@mdagost mdagost merged commit bac1a9d into ShopRunner:master Aug 18, 2017
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.

3 participants
0