59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
import re
|
|
import sys
|
|
from os.path import dirname
|
|
from adapt.intent import IntentBuilder
|
|
from mycroft import MycroftSkill, intent_handler
|
|
|
|
class MeetingModeSkill(MycroftSkill):
|
|
"""
|
|
Skill to show or hide a DO NOT DISTURB message
|
|
"""
|
|
|
|
def __init__(self):
|
|
super().__init__("MeetingModeSkill")
|
|
self.dnd_image = None
|
|
self.html_resources = "file://" + dirname(__file__) + '/res/'
|
|
self.on_settings_changed()
|
|
|
|
def on_settings_changed(self):
|
|
self.dnd_image = self.settings.get('dnd_image', 'do-not-disturb.png')
|
|
|
|
def initialize(self):
|
|
self.gui.register_handler('MeetingModeSkill.doNotDisturb',
|
|
self.handle_do_not_disturb_intent)
|
|
self.gui.register_handler('MeetingModeSkill.cancelDoNotDisturb',
|
|
self.handle_cancel_do_not_disturb_intent)
|
|
|
|
@intent_handler(IntentBuilder('handle_do_not_disturb_intent').require('do-not-disturb'))
|
|
def handle_do_not_disturb_intent(self, message):
|
|
self.gui.clear()
|
|
self.enclosure.display_manager.remove_active()
|
|
html = """<!doctype html>
|
|
<html language='en'>
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<title>DO NOT DISTURB</title>
|
|
<style>
|
|
html {
|
|
background: url('%s') no-repeat center center fixed;
|
|
background-size: cover;
|
|
}
|
|
</style>
|
|
<body>
|
|
|
|
</body>
|
|
</html>
|
|
""" % self.dnd_image
|
|
self.gui.show_html(html, resource_url=self.html_resources, override_idle=True)
|
|
|
|
@intent_handler(IntentBuilder('handle_cancel_do_not_disturb_intent').require('cancel-do-not-disturb'))
|
|
def handle_cancel_do_not_disturb_intent(self, message):
|
|
self.gui.clear()
|
|
|
|
def stop(self):
|
|
pass
|
|
|
|
|
|
def create_skill():
|
|
return MeetingModeSkill()
|