Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfee1c8

Browse files
committed
feat(config): support custom configuration directory via YASB_CONFIG_HOME
1 parent8f84e75 commitcfee1c8

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

‎src/core/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
fromtypingimportUnion
88
fromcore.validation.configimportCONFIG_SCHEMA
99
fromcore.utils.alert_dialogimportraise_info_alert
10-
#from cssutils import CSSParser
1110
fromcerberusimportValidator,schema
1211
fromyaml.parserimportParserError
1312
fromyamlimportsafe_load,dump

‎src/core/utils/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ def parse_arguments():
195195
sys.exit(0)
196196

197197
elifargs.command=='log':
198-
log_file=os.path.join(os.path.expanduser("~"),".config","yasb","yasb.log")
198+
config_home=os.getenv('YASB_CONFIG_HOME')ifos.getenv('YASB_CONFIG_HOME')elseos.path.join(os.path.expanduser("~"),".config","yasb")
199+
log_file=os.path.join(config_home,"yasb.log")
199200
ifnotos.path.exists(log_file):
200201
print("Log file does not exist. Please restart YASB to generate logs.")
201202
sys.exit(1)

‎src/core/utils/themes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,15 @@ def install_theme(self):
288288
# Show the dialog and check the user's response
289289
ifdialog.exec()==QDialog.DialogCode.Accepted:
290290
try:
291-
subprocess.run(["yasbc","stop"],creationflags=subprocess.CREATE_NO_WINDOW)
291+
subprocess.run(["yasbc","stop"],creationflags=subprocess.CREATE_NO_WINDOW,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
292292
# Define the URLs for the files
293293
base_url=f"https://raw.githubusercontent.com/amnweb/yasb-themes/main/themes/{self.theme_data['id']}"
294294
config_url=f"{base_url}/config.yaml"
295295
styles_url=f"{base_url}/styles.css"
296296

297-
# Define the destination paths
298-
home_dir=os.path.expanduser("~")
299-
config_path=os.path.join(home_dir,".config","yasb","config.yaml")
300-
styles_path=os.path.join(home_dir,".config","yasb","styles.css")
297+
config_home=os.getenv('YASB_CONFIG_HOME')ifos.getenv('YASB_CONFIG_HOME')elseos.path.join(os.path.expanduser("~"),".config","yasb")
298+
config_path=os.path.join(config_home,"config.yaml")
299+
styles_path=os.path.join(config_home,"styles.css")
301300

302301
# Create the directory if it doesn't exist
303302
os.makedirs(os.path.dirname(config_path),exist_ok=True)
@@ -307,13 +306,13 @@ def install_theme(self):
307306
styles_response.raise_for_status()
308307
withopen(styles_path,'wb')asstyles_file:
309308
styles_file.write(styles_response.content)
310-
309+
311310
# Download and save the config.yaml file
312311
config_response=requests.get(config_url)
313312
config_response.raise_for_status()
314313
withopen(config_path,'wb')asconfig_file:
315314
config_file.write(config_response.content)
316-
subprocess.run(["yasbc","start"],creationflags=subprocess.CREATE_NO_WINDOW)
315+
subprocess.run(["yasbc","start"],creationflags=subprocess.CREATE_NO_WINDOW,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
317316
exceptExceptionase:
318317
QMessageBox.critical(self,'Error',f"Failed to install theme:{str(e)}")
319318

@@ -349,7 +348,8 @@ def init_ui(self):
349348
self.placeholder_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
350349
layout.addWidget(self.placeholder_label)
351350

352-
self.backup_info=QLabel("Backup your current theme before installing a new one. You can do this by copying the <b>config.yaml</b> and <b>styles.css</b> files from the <b><i>.config/yasb</i></b> directory to a safe location.")
351+
config_home=os.getenv('YASB_CONFIG_HOME')ifos.getenv('YASB_CONFIG_HOME')elseos.path.join(os.path.expanduser("~"),".config","yasb")
352+
self.backup_info=QLabel(f"Backup your current theme before installing a new one. You can do this by copying the <b>config.yaml</b> and <b>styles.css</b> files from the <b><i>{config_home}</i></b> directory to a safe location.")
353353
self.backup_info.setWordWrap(True)
354354
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")
355355
self.backup_info.hide()

‎src/main.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
importos
21
importasyncio
32
importlogging
43
importsys
@@ -16,9 +15,6 @@
1615
importctypes.wintypes
1716
fromcore.utils.win32.windowsimportWindowsTaskbar
1817

19-
# Set font engine to GDI as DirectWrite causes issues with some fonts in PyQt6.8
20-
os.environ["QT_QPA_PLATFORM"]="windows:fontengine=gdi"
21-
2218
logging.getLogger('asyncio').setLevel(logging.WARNING)
2319

2420
defmain():

‎src/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
SCRIPT_PATH=os.path.dirname(os.path.abspath(__file__))
77
GITHUB_URL="https://github.com/amnweb/yasb"
88
GITHUB_THEME_URL="https://github.com/amnweb/yasb-themes"
9-
BUILD_VERSION="1.6.3"
9+
BUILD_VERSION="1.6.4"
1010
# Development Settings
1111
DEBUG=False
1212
# Configuration Settings
13-
DEFAULT_CONFIG_DIRECTORY=".config\\yasb"
13+
DEFAULT_CONFIG_DIRECTORY=os.getenv('YASB_CONFIG_HOME',".config\\yasb")
1414
DEFAULT_STYLES_FILENAME="styles.css"
1515
DEFAULT_CONFIG_FILENAME="config.yaml"
16-
DEFAULT_LOG_FILENAME="yasb.log"
16+
DEFAULT_LOG_FILENAME="yasb.log"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp