Make G (growl) send a Notification

cpsdqs/unified-input
cpsdqs 7 years ago
parent ec4897ae2a
commit 5cbb3ea2c9
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 14
      jssrc/term_screen.js

@ -909,6 +909,18 @@ class TermScreen {
}) })
} }
showNotification (text) {
// TODO: request permission earlier
// the requestPermission should be user-triggered; asking upfront seems
// a little awkward
if (Notification && Notification.permission === 'granted') {
let notification = new Notification('ESPTerm', {
body: text
});
notification.addEventListener('click', () => window.focus());
}
}
load (str) { load (str) {
const content = str.substr(1); const content = str.substr(1);
@ -922,6 +934,8 @@ class TermScreen {
case 'B': case 'B':
this.beep(); this.beep();
break; break;
case 'G':
this.showNotification(content);
default: default:
console.warn(`Bad data message type; ignoring.\n${JSON.stringify(content)}`) console.warn(`Bad data message type; ignoring.\n${JSON.stringify(content)}`)
} }

Loading…
Cancel
Save