MycroftOS: Update mycroftos-enclosure skill
This commit is contained in:
parent
f95dec9fa5
commit
53307696cb
|
@ -40,6 +40,10 @@ class MycroftOS(MycroftSkill):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Handle settings change
|
||||||
|
self.settings.set_changed_callback(self.on_websettings_changed)
|
||||||
|
self.on_websettings_changed()
|
||||||
|
|
||||||
# Handle the 'waking' visual
|
# Handle the 'waking' visual
|
||||||
self.add_event('recognizer_loop:wakeword',
|
self.add_event('recognizer_loop:wakeword',
|
||||||
self.handle_listener_started)
|
self.handle_listener_started)
|
||||||
|
@ -76,7 +80,11 @@ class MycroftOS(MycroftSkill):
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('In MycroftOS Skill')
|
LOG.exception('In MycroftOS Skill')
|
||||||
|
|
||||||
self.settings.set_changed_callback(self.on_websettings_changed)
|
def on_websettings_changed(self):
|
||||||
|
if self.settings.get("sshd") is True:
|
||||||
|
self.enable_ssh()
|
||||||
|
if self.settings.get("airplay") is True:
|
||||||
|
self.enable_airplay()
|
||||||
|
|
||||||
# System volume
|
# System volume
|
||||||
#def on_volume_set(self, message):
|
#def on_volume_set(self, message):
|
||||||
|
@ -165,31 +173,37 @@ class MycroftOS(MycroftSkill):
|
||||||
def on_shutdown(self, message):
|
def on_shutdown(self, message):
|
||||||
self.speak("Till next time")
|
self.speak("Till next time")
|
||||||
sleep(5)
|
sleep(5)
|
||||||
os.system("sudo shutdown --poweroff now")
|
os.system("sudo halt")
|
||||||
|
|
||||||
def on_reboot(self, message):
|
def on_reboot(self, message):
|
||||||
self.speak("I'll be right back")
|
self.speak("I'll be right back")
|
||||||
sleep(5)
|
sleep(5)
|
||||||
os.system("sudo shutdown --reboot now")
|
os.system("sudo reboot")
|
||||||
|
|
||||||
def enable_airplay(self, message):
|
|
||||||
os.system("sudo systemctl enable shairport-sync.service")
|
|
||||||
os.system("sudo systemctl start shairport-sync.service")
|
|
||||||
|
|
||||||
def disable_airplay(self, message):
|
|
||||||
os.system("sudo systemctl disable shairport-sync.service")
|
|
||||||
os.system("sudo systemctl stop shairport-sync.service")
|
|
||||||
|
|
||||||
|
|
||||||
# Intent handlers
|
# Intent handlers
|
||||||
@intent_handler(IntentBuilder("").require("EnableAirPlay"))
|
@intent_file_handler("EnableSSH.intent")
|
||||||
def handle_enable_airplay_intent(self, message):
|
def enable_ssh(self, message):
|
||||||
self.enable_airplay()
|
os.system("sudo systemctl enable sshd.service")
|
||||||
|
os.system("sudo systemctl start sshd.service")
|
||||||
|
self.speak_dialog("EnableSSH")
|
||||||
|
|
||||||
|
@intent_file_handler("DisableSSH.intent")
|
||||||
|
def disable_ssh(self, message):
|
||||||
|
os.system("sudo systemctl disable sshd.service")
|
||||||
|
os.system("sudo systemctl stop sshd.service")
|
||||||
|
self.speak_dialog("DisableSSH")
|
||||||
|
|
||||||
|
@intent_file_handler("EnableAirPlay.intent")
|
||||||
|
def enable_airplay(self, message):
|
||||||
|
os.system("sudo systemctl enable shairport-sync.service")
|
||||||
|
os.system("sudo systemctl start shairport-sync.service")
|
||||||
self.speak_dialog("EnableAirPlay")
|
self.speak_dialog("EnableAirPlay")
|
||||||
|
|
||||||
@intent_handler(IntentBuilder("").require("DisableAirPlay"))
|
@intent_file_handler("DisableAirPlay.intent")
|
||||||
def handle_disable_airplay_intent(self, message):
|
def disable_airplay(self, message):
|
||||||
self.disable_airplay()
|
os.system("sudo systemctl disable shairport-sync.service")
|
||||||
|
os.system("sudo systemctl stop shairport-sync.service")
|
||||||
self.speak_dialog("DisableAirPlay")
|
self.speak_dialog("DisableAirPlay")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Secure shell is stopped and disabled
|
|
@ -0,0 +1 @@
|
||||||
|
Secure shell is enabled and started
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"name": "MycroftOS System",
|
||||||
|
"skillMetadata": {
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"name": "Enabled services",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"label": "Secure Shell (SSH)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sshd",
|
||||||
|
"type": "checkbox",
|
||||||
|
"label": "Enabled",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"label": "AirPlay audio player (v1)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "airplay",
|
||||||
|
"type": "checkbox",
|
||||||
|
"label": "Enabled",
|
||||||
|
"value": "false"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
Disable airplay
|
||||||
|
Disable air play
|
||||||
|
Disable shareport sync
|
||||||
|
Disable share port sync
|
||||||
|
Disable shareport
|
||||||
|
Disable share port
|
|
@ -1 +0,0 @@
|
||||||
Disable airplay
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Disable S S H
|
||||||
|
Disable S.S.H.
|
||||||
|
Disable SSH
|
||||||
|
Disable secure shell
|
|
@ -0,0 +1,7 @@
|
||||||
|
Enable airplay
|
||||||
|
Enable air play
|
||||||
|
Enable shareport sync
|
||||||
|
Enable share port sync
|
||||||
|
Enable shareport
|
||||||
|
Enable share port
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Enable airplay
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Enable S S H
|
||||||
|
Enable S.S.H.
|
||||||
|
Enable SSH
|
||||||
|
Enable secure shell
|
Loading…
Reference in New Issue