MycroftOS: Try to enable/disable Airplay via enclosure-skill

This commit is contained in:
Peter Steenbergen 2020-01-06 21:12:43 +01:00
parent d5b81abe22
commit 64bac8c138
8 changed files with 47 additions and 3 deletions

View File

@ -76,6 +76,7 @@ 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)
# System volume # System volume
#def on_volume_set(self, message): #def on_volume_set(self, message):
@ -93,7 +94,6 @@ class MycroftOS(MycroftSkill):
# self.muted = False # self.muted = False
# call(['pactl', 'set-sink-mute', '0', '0']) # call(['pactl', 'set-sink-mute', '0', '0'])
# Cleanup # Cleanup
def shutdown(self): def shutdown(self):
# Gotta clean up manually since not using add_event() # Gotta clean up manually since not using add_event()
@ -158,6 +158,8 @@ class MycroftOS(MycroftSkill):
self.loading = False self.loading = False
if is_paired(): if is_paired():
os.system("fbv -f -d 1 /opt/mycroft/skills/mycroftos-enclosure-skill/ui/background.png > /dev/null 2>&1") os.system("fbv -f -d 1 /opt/mycroft/skills/mycroftos-enclosure-skill/ui/background.png > /dev/null 2>&1")
self.speak_dialog('finished.booting')
# System actions # System actions
def on_shutdown(self, message): def on_shutdown(self, message):
@ -170,6 +172,26 @@ class MycroftOS(MycroftSkill):
sleep(5) sleep(5)
os.system("sudo shutdown --reboot now") os.system("sudo shutdown --reboot now")
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_handler(IntentBuilder("").require("EnableAirPlay"))
def handle_enable_airplay_intent(self, message):
self.enable_airplay()
self.speak_dialog("EnableAirPlay")
@intent_handler(IntentBuilder("").require("DisableAirPlay"))
def handle_disable_airplay_intent(self, message):
self.disable_airplay()
self.speak_dialog("DisableAirPlay")
def create_skill(): def create_skill():
return MycroftOS() return MycroftOS()

View File

@ -0,0 +1,4 @@
I have now finished booting up.
I am now ready.
Hi, this is mycroft and I am ready to work.
You can get started with mycroft.

View File

@ -1,2 +0,0 @@
Rebooting now, I'll be right back
Restarting, back in a few minutes

View File

@ -0,0 +1,16 @@
[Unit]
Description=Shairport-sync
Wants=network.target
Requires=avahi-daemon.service
After=network.target sound.target avahi-daemon.service
[Service]
Type=simple
# Avahi daemon needs some time until fully ready
ExecStartPre=/bin/sleep 3
ExecStart=/usr/bin/shairport-sync
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target