diff --git a/build.sh b/build.sh index aa1e255..2125bfb 100755 --- a/build.sh +++ b/build.sh @@ -33,3 +33,5 @@ pyinstaller --name "volvodisplay" \ main.py echo "Build complete. Binary is in 'dist/volvodisplay'" +cp config.json dist/ +echo "Copied config.json to 'dist/'" diff --git a/main.py b/main.py index 47b4b03..f002cda 100644 --- a/main.py +++ b/main.py @@ -39,7 +39,15 @@ class Backend(QObject): self.timer.start(2000) # Poll every 2 seconds def load_config(self): - config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.json") + # Determine path based on run mode (Script vs Frozen/Compiled) + if getattr(sys, 'frozen', False): + # If run as a compiled exe, look in the same directory as the executable + application_path = os.path.dirname(sys.executable) + else: + # If run as a script, look in the directory of the script + application_path = os.path.dirname(os.path.abspath(__file__)) + + config_path = os.path.join(application_path, "config.json") if os.path.exists(config_path): try: with open(config_path, 'r') as f: