From 87b8829cbd8743c985b4049fb62e4250b7b49bda Mon Sep 17 00:00:00 2001 From: Takeshi Watanabe Date: Mon, 18 Dec 2023 17:05:04 +0900 Subject: [PATCH 1/2] Use sys.executable to launch python scripts --- configure.py | 4 ++-- main.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.py b/configure.py index d98dab21..01ef0bec 100755 --- a/configure.py +++ b/configure.py @@ -364,14 +364,14 @@ def on_theme_change(self, e=None): self.load_theme_preview() def on_theme_editor_click(self): - subprocess.Popen(os.path.join(os.getcwd(), "theme-editor.py") + " \"" + self.theme_cb.get() + "\"", shell=True) + subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "theme-editor.py"), self.theme_cb.get()]) def on_save_click(self): self.save_config_values() def on_saverun_click(self): self.save_config_values() - subprocess.Popen(os.path.join(os.getcwd(), "main.py"), shell=True) + subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "main.py")]) self.window.destroy() def on_brightness_change(self, e=None): diff --git a/main.py b/main.py index 0402f6e7..3a6430a4 100755 --- a/main.py +++ b/main.py @@ -108,7 +108,7 @@ def on_signal_caught(signum, frame=None): def on_configure_tray(tray_icon, item): logger.info("Configure from tray icon") - subprocess.Popen(os.path.join(os.getcwd(), "configure.py"), shell=True) + subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "configure.py")]) clean_stop(tray_icon) From 2efe7ba54ef57b953d8b768429336cd2a4e80c39 Mon Sep 17 00:00:00 2001 From: take-cheeze Date: Thu, 11 Jan 2024 00:05:56 +0900 Subject: [PATCH 2/2] Detach process when switching mode --- configure.py | 5 ++++- main.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index 01ef0bec..052db5d0 100755 --- a/configure.py +++ b/configure.py @@ -371,7 +371,10 @@ def on_save_click(self): def on_saverun_click(self): self.save_config_values() - subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "main.py")]) + kwargs = {} + if hasattr(subprocess, "DETACHED_PROCESS"): + kwargs["creationflags"] = subprocess.DETACHED_PROCESS + subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "main.py")], **kwargs) self.window.destroy() def on_brightness_change(self, e=None): diff --git a/main.py b/main.py index 3a6430a4..8218b616 100755 --- a/main.py +++ b/main.py @@ -108,7 +108,10 @@ def on_signal_caught(signum, frame=None): def on_configure_tray(tray_icon, item): logger.info("Configure from tray icon") - subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "configure.py")]) + kwargs = {} + if hasattr(subprocess, "DETACHED_PROCESS"): + kwargs["creationflags"] = subprocess.DETACHED_PROCESS + subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "configure.py")], **kwargs) clean_stop(tray_icon)