File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed
src/jupyter_contrib_nbextensions/nbextensions/notify Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,13 @@ Add this file to $(ipython locate)/nbextensions/
11
11
define ( [
12
12
"jquery" ,
13
13
"base/js/namespace" ,
14
- ] , function ( $ , IPython ) {
14
+ "require" ,
15
+ ] , function ( $ , IPython , require ) {
15
16
"use strict" ;
16
17
17
18
var params = {
18
- sticky : false
19
+ sticky : false ,
20
+ sound : false
19
21
} ;
20
22
21
23
var current_time = function ( ) {
@@ -102,10 +104,15 @@ define([
102
104
var notify = function ( ) {
103
105
var elapsed_time = current_time ( ) - start_time ;
104
106
if ( enabled && ! first_start && ! busy_kernel && elapsed_time >= min_time ) {
105
- var n = new Notification ( IPython . notebook . notebook_name , {
107
+ var opts = {
106
108
body : "Kernel is now idle\n(ran for " + Math . round ( elapsed_time ) + " secs)" ,
109
+ icon : "/static/base/images/favicon.ico" ,
107
110
requireInteraction : params . sticky
108
- } ) ;
111
+ } ;
112
+ if ( params . sound ) {
113
+ opts [ "sound" ] = require . toUrl ( "./notify.mp3" ) ;
114
+ }
115
+ var n = new Notification ( IPython . notebook . notebook_name , opts ) ;
109
116
n . onclick = function ( event ) { window . focus ( ) ; }
110
117
}
111
118
if ( first_start ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ Main: notify.js
9
9
Compatibility : 4.x, 5.x
10
10
Parameters :
11
11
- name : notify.sticky
12
- description : Require interactions on notifications to dismiss them.
12
+ description : Require interactions on notifications to dismiss them. (Chrome only)
13
+ input_type : checkbox
14
+ default : false
15
+ - name : notify.sound
16
+ description : Play notification sound. (Not yet supported in browsers)
13
17
input_type : checkbox
14
18
default : false
Original file line number Diff line number Diff line change @@ -19,14 +19,23 @@ notebook's metadata and restored when the notebook is re-opened.
19
19
You may configure the plugin so that notifications require manual dismissal
20
20
before disappearing. Browser support is limited, see
21
21
[ here] ( https://developer.mozilla.org/en-US/docs/Web/API/notification/requireInteraction )
22
- to check if your browser supports this.
22
+ to check if your browser supports this. You may also configure the plugin so
23
+ that notifications play a sound, although this is currently
24
+ [ unsupported] ( https://developer.mozilla.org/en-US/docs/Web/API/notification/sound )
25
+ in all major browsers.
23
26
24
27
![ notification] ( notification.png " notification ")
25
28
26
29
27
30
## Original Source
28
31
This extension originally comes from [ @sjpfenniger ] ( https://github.com/sjpfenninger ) 's [ GitHub repository] ( https://github.com/sjpfenninger/ipython-extensions ) .
29
32
33
+ ## Credits
34
+
35
+ This extension contains sounds created by RSilveira_88 on fresound.org, licensed
36
+ under the CC-BY 3.0 License. Modifications by morrisjim. You may find the
37
+ modified version [ here] ( http://freesound.org/people/morrisjm/sounds/268756/ ) and
38
+ the original [ here] ( http://freesound.org/people/RSilveira_88/sounds/216306/ ) .
30
39
31
40
## License
32
41
You can’t perform that action at this time.
0 commit comments