Improve closing of applications

Try to close using name, if that fails try using the command in the Exec field
in the Desktop file.
This commit is contained in:
Åke Forslund 2019-11-06 11:56:06 +01:00
parent 78557ec064
commit e5677e4730

View File

@ -69,7 +69,15 @@ class DesktopLauncherSkill(MycroftSkill):
def handle_close_desktop_app(self, message):
"""Close application using killall -9."""
app_name = message.data.get('Application')
subprocess.call(['killall', '-9', app_name])
self.log.info('Killing {}'.format(app_name))
if subprocess.call(['killall', '-9', app_name]):
# Couldn't be killed try to get executable from desktop file
apps = self.appmap.get(app_name)
# Try to find executable name
if apps:
app_name = apps[0].get_string('Exec')
subprocess.call(['killall', '-9', app_name])
@intent_handler(IntentBuilder('LaunchWebsiteIntent')
.require('LaunchKeyword').require('Website'))