Skip to content

Commit

Permalink
refactor(bar_manager, tray): replace QProcess with os.execl for appli…
Browse files Browse the repository at this point in the history
…cation reload
  • Loading branch information
amnweb committed Jan 13, 2025
1 parent d7a6239 commit 7c949f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/core/bar_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import suppress
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QScreen
from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot, QProcess, QCoreApplication
from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot
from core.bar import Bar
from core.utils.widget_builder import WidgetBuilder
from core.utils.utilities import get_screen_by_name
Expand Down Expand Up @@ -54,19 +54,15 @@ def on_config_modified(self):
return
if config and (config != self.config):
if any(config[key] != self.config[key] for key in ['bars', 'widgets', 'komorebi', 'debug','hide_taskbar']):
#os.execl(sys.executable, sys.executable, *sys.argv)
QCoreApplication.quit()
QProcess.startDetached(sys.executable, sys.argv)
os.execl(sys.executable, sys.executable, *sys.argv)
else:
self.config = config
logging.info("Successfully loaded updated config and re-initialised all bars.")

@pyqtSlot(QScreen)
def on_screens_update(self, _screen: QScreen) -> None:
logging.info("Screens updated. Re-initialising all bars.")
#os.execl(sys.executable, sys.executable, *sys.argv)
QCoreApplication.quit()
QProcess.startDetached(sys.executable, sys.argv)
os.execl(sys.executable, sys.executable, *sys.argv)

def run_listeners_in_threads(self):
for listener in self.widget_event_listeners:
Expand Down
5 changes: 2 additions & 3 deletions src/core/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import winshell
from PyQt6.QtWidgets import QSystemTrayIcon, QMenu, QMessageBox
from PyQt6.QtGui import QIcon, QGuiApplication
from PyQt6.QtCore import QCoreApplication, QSize, Qt, QProcess
from PyQt6.QtCore import QCoreApplication, QSize, Qt
from core.bar_manager import BarManager
from settings import GITHUB_URL, SCRIPT_PATH, APP_NAME, APP_NAME_FULL, DEFAULT_CONFIG_DIRECTORY, GITHUB_THEME_URL, BUILD_VERSION
from core.config import get_config
Expand Down Expand Up @@ -203,8 +203,7 @@ def run_komorebi_reload():

def _reload_application(self):
logging.info("Reloading Application...")
QCoreApplication.quit()
QProcess.startDetached(sys.executable, sys.argv)
os.execl(sys.executable, sys.executable, *sys.argv)

def _exit_application(self):
logging.info("Exiting Application from tray...")
Expand Down

0 comments on commit 7c949f3

Please sign in to comment.