diff --git a/src/core/config.py b/src/core/config.py index 21b1f22..5c3259f 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -7,7 +7,6 @@ from typing import Union from core.validation.config import CONFIG_SCHEMA from core.utils.alert_dialog import raise_info_alert -#from cssutils import CSSParser from cerberus import Validator, schema from yaml.parser import ParserError from yaml import safe_load, dump diff --git a/src/core/utils/cli.py b/src/core/utils/cli.py index c7783a9..533a897 100644 --- a/src/core/utils/cli.py +++ b/src/core/utils/cli.py @@ -195,7 +195,8 @@ def parse_arguments(): sys.exit(0) elif args.command == 'log': - log_file = os.path.join(os.path.expanduser("~"), ".config", "yasb", "yasb.log") + config_home = os.getenv('YASB_CONFIG_HOME') if os.getenv('YASB_CONFIG_HOME') else os.path.join(os.path.expanduser("~"), ".config", "yasb") + log_file = os.path.join(config_home, "yasb.log") if not os.path.exists(log_file): print("Log file does not exist. Please restart YASB to generate logs.") sys.exit(1) diff --git a/src/core/utils/themes.py b/src/core/utils/themes.py index 2c74dea..523e2ff 100644 --- a/src/core/utils/themes.py +++ b/src/core/utils/themes.py @@ -288,16 +288,15 @@ def install_theme(self): # Show the dialog and check the user's response if dialog.exec() == QDialog.DialogCode.Accepted: try: - subprocess.run(["yasbc", "stop"], creationflags=subprocess.CREATE_NO_WINDOW) + subprocess.run(["yasbc", "stop"], creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Define the URLs for the files base_url = f"https://raw.githubusercontent.com/amnweb/yasb-themes/main/themes/{self.theme_data['id']}" config_url = f"{base_url}/config.yaml" styles_url = f"{base_url}/styles.css" - # Define the destination paths - home_dir = os.path.expanduser("~") - config_path = os.path.join(home_dir, ".config", "yasb", "config.yaml") - styles_path = os.path.join(home_dir, ".config", "yasb", "styles.css") + config_home = os.getenv('YASB_CONFIG_HOME') if os.getenv('YASB_CONFIG_HOME') else os.path.join(os.path.expanduser("~"), ".config", "yasb") + config_path = os.path.join(config_home, "config.yaml") + styles_path = os.path.join(config_home, "styles.css") # Create the directory if it doesn't exist os.makedirs(os.path.dirname(config_path), exist_ok=True) @@ -307,13 +306,13 @@ def install_theme(self): styles_response.raise_for_status() with open(styles_path, 'wb') as styles_file: styles_file.write(styles_response.content) - + # Download and save the config.yaml file config_response = requests.get(config_url) config_response.raise_for_status() with open(config_path, 'wb') as config_file: config_file.write(config_response.content) - subprocess.run(["yasbc", "start"], creationflags=subprocess.CREATE_NO_WINDOW) + subprocess.run(["yasbc", "start"], creationflags=subprocess.CREATE_NO_WINDOW, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except Exception as e: QMessageBox.critical(self, 'Error', f"Failed to install theme: {str(e)}") @@ -349,7 +348,8 @@ def init_ui(self): self.placeholder_label.setAlignment(Qt.AlignmentFlag.AlignCenter) layout.addWidget(self.placeholder_label) - self.backup_info = QLabel("Backup your current theme before installing a new one. You can do this by copying the config.yaml and styles.css files from the .config/yasb directory to a safe location.") + config_home = os.getenv('YASB_CONFIG_HOME') if os.getenv('YASB_CONFIG_HOME') else os.path.join(os.path.expanduser("~"), ".config", "yasb") + self.backup_info = QLabel(f"Backup your current theme before installing a new one. You can do this by copying the config.yaml and styles.css files from the {config_home} directory to a safe location.") self.backup_info.setWordWrap(True) self.backup_info.setStyleSheet("color:#fff; background-color: rgba(166, 16, 48, 0.3);border-radius:6px;border:1px solid rgba(166, 16, 48, 0.5);padding:4px 8px;font-size:11px;font-family:'Segoe UI';margin:14px 20px 0 14px") self.backup_info.hide() diff --git a/src/main.py b/src/main.py index f418edd..2b99c9e 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,3 @@ -import os import asyncio import logging import sys @@ -16,9 +15,6 @@ import ctypes.wintypes from core.utils.win32.windows import WindowsTaskbar -# Set font engine to GDI as DirectWrite causes issues with some fonts in PyQt6.8 -os.environ["QT_QPA_PLATFORM"] = "windows:fontengine=gdi" - logging.getLogger('asyncio').setLevel(logging.WARNING) def main(): diff --git a/src/settings.py b/src/settings.py index 4177c32..8a4b498 100644 --- a/src/settings.py +++ b/src/settings.py @@ -6,11 +6,11 @@ SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) GITHUB_URL = "https://github.com/amnweb/yasb" GITHUB_THEME_URL = "https://github.com/amnweb/yasb-themes" -BUILD_VERSION = "1.6.3" +BUILD_VERSION = "1.6.4" # Development Settings DEBUG = False # Configuration Settings -DEFAULT_CONFIG_DIRECTORY = ".config\\yasb" +DEFAULT_CONFIG_DIRECTORY = os.getenv('YASB_CONFIG_HOME', ".config\\yasb") DEFAULT_STYLES_FILENAME = "styles.css" DEFAULT_CONFIG_FILENAME = "config.yaml" -DEFAULT_LOG_FILENAME = "yasb.log" +DEFAULT_LOG_FILENAME = "yasb.log" \ No newline at end of file