From e5677e473097dafe78d91a6c562da1b110af6285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Wed, 6 Nov 2019 11:56:06 +0100 Subject: [PATCH] Improve closing of applications Try to close using name, if that fails try using the command in the Exec field in the Desktop file. --- __init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 47840e7..1eab375 100644 --- a/__init__.py +++ b/__init__.py @@ -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'))