mirror of
https://github.com/JuanCanham/skill-desktop-launcher.git
synced 2024-11-22 17:00:10 +00:00
Merge pull request #2 from eClarity/master
Add close application feature
This commit is contained in:
commit
2de1b3abb3
10
__init__.py
10
__init__.py
@ -19,6 +19,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from adapt.intent import IntentBuilder
|
from adapt.intent import IntentBuilder
|
||||||
from adapt.tools.text.tokenizer import EnglishTokenizer
|
from adapt.tools.text.tokenizer import EnglishTokenizer
|
||||||
@ -74,6 +75,11 @@ class DesktopLauncherSkill(MycroftSkill):
|
|||||||
"Application").build()
|
"Application").build()
|
||||||
self.register_intent(launch_intent, self.handle_launch_desktop_app)
|
self.register_intent(launch_intent, self.handle_launch_desktop_app)
|
||||||
|
|
||||||
|
close_intent = IntentBuilder(
|
||||||
|
"CloseDesktopApplicationIntent").require("CloseKeyword").require(
|
||||||
|
"Application").build()
|
||||||
|
self.register_intent(close_intent, self.handle_close_desktop_app)
|
||||||
|
|
||||||
launch_website_intent = IntentBuilder(
|
launch_website_intent = IntentBuilder(
|
||||||
"LaunchWebsiteIntent").require("LaunchKeyword").require(
|
"LaunchWebsiteIntent").require("LaunchKeyword").require(
|
||||||
"Website").build()
|
"Website").build()
|
||||||
@ -90,6 +96,10 @@ class DesktopLauncherSkill(MycroftSkill):
|
|||||||
if apps and len(apps) > 0:
|
if apps and len(apps) > 0:
|
||||||
apps[0].launch()
|
apps[0].launch()
|
||||||
|
|
||||||
|
def handle_close_desktop_app(self, message):
|
||||||
|
app_name = message.data.get('Application')
|
||||||
|
subprocess.call( [ "killall", "-9", app_name ] )
|
||||||
|
|
||||||
def handle_launch_website(self, message):
|
def handle_launch_website(self, message):
|
||||||
site = message.data.get("Website")
|
site = message.data.get("Website")
|
||||||
webbrowser.open(IFL_TEMPLATE % (urllib2.quote(site)))
|
webbrowser.open(IFL_TEMPLATE % (urllib2.quote(site)))
|
||||||
|
2
vocab/en-us/CloseKeyword.voc
Normal file
2
vocab/en-us/CloseKeyword.voc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
close
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user