fix: restore Feishin window dimension persistence and default to 1280x800
This commit is contained in:
parent
360f96c653
commit
7e815d4a51
10
install.sh
10
install.sh
@ -440,17 +440,25 @@ if os.path.exists(var_app):
|
|||||||
|
|
||||||
for td in target_dirs:
|
for td in target_dirs:
|
||||||
if os.path.exists(td):
|
if os.path.exists(td):
|
||||||
# Clean up / sanitize invalid Electron theme strings in config.json, preferences.json, settings.json
|
# Clean up / sanitize invalid Electron theme strings and ensure comfortable window bounds
|
||||||
for fn in ['config.json', 'preferences.json', 'settings.json']:
|
for fn in ['config.json', 'preferences.json', 'settings.json']:
|
||||||
fp = os.path.join(td, fn)
|
fp = os.path.join(td, fn)
|
||||||
if os.path.exists(fp):
|
if os.path.exists(fp):
|
||||||
try:
|
try:
|
||||||
with open(fp, 'r', encoding='utf-8') as f: data = json.load(f)
|
with open(fp, 'r', encoding='utf-8') as f: data = json.load(f)
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
|
mod = False
|
||||||
if list(data.keys()) == ['theme'] and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
if list(data.keys()) == ['theme'] and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
os.remove(fp)
|
os.remove(fp)
|
||||||
|
continue
|
||||||
elif 'theme' in data and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
elif 'theme' in data and data['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
data['theme'] = 'dark'
|
data['theme'] = 'dark'
|
||||||
|
mod = True
|
||||||
|
bounds = data.get('bounds', {})
|
||||||
|
if isinstance(bounds, dict) and (bounds.get('width', 0) < 1000 or bounds.get('height', 0) < 700):
|
||||||
|
data['bounds'] = {'x': bounds.get('x', 50), 'y': bounds.get('y', 50), 'width': 1280, 'height': 800}
|
||||||
|
mod = True
|
||||||
|
if mod:
|
||||||
with open(fp, 'w', encoding='utf-8') as f: json.dump(data, f, indent=2)
|
with open(fp, 'w', encoding='utf-8') as f: json.dump(data, f, indent=2)
|
||||||
except Exception: pass
|
except Exception: pass
|
||||||
" 2>/dev/null || true
|
" 2>/dev/null || true
|
||||||
|
|||||||
@ -1298,7 +1298,7 @@ def sync_feishin(bg, surface, current_line, fg, accent, sub_accent, is_dark, var
|
|||||||
with open(os.path.join(themes_dir, "quickshell.json"), 'w', encoding='utf-8') as f:
|
with open(os.path.join(themes_dir, "quickshell.json"), 'w', encoding='utf-8') as f:
|
||||||
json.dump(qs_json, f, indent=2)
|
json.dump(qs_json, f, indent=2)
|
||||||
|
|
||||||
# Ensure config.json, preferences.json, and settings.json maintain valid Electron themeSource ("dark" or "light")
|
# Ensure config.json, preferences.json, and settings.json maintain valid Electron themeSource ("dark" or "light") and comfortable window bounds
|
||||||
valid_electron_theme = "dark" if is_dark else "light"
|
valid_electron_theme = "dark" if is_dark else "light"
|
||||||
for conf_file_name in ['config.json', 'preferences.json', 'settings.json']:
|
for conf_file_name in ['config.json', 'preferences.json', 'settings.json']:
|
||||||
conf_path = os.path.join(base_dir, conf_file_name)
|
conf_path = os.path.join(base_dir, conf_file_name)
|
||||||
@ -1307,10 +1307,25 @@ def sync_feishin(bg, surface, current_line, fg, accent, sub_accent, is_dark, var
|
|||||||
with open(conf_path, 'r', encoding='utf-8') as f:
|
with open(conf_path, 'r', encoding='utf-8') as f:
|
||||||
cdata = json.load(f)
|
cdata = json.load(f)
|
||||||
if isinstance(cdata, dict):
|
if isinstance(cdata, dict):
|
||||||
|
modified = False
|
||||||
if list(cdata.keys()) == ['theme'] and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
if list(cdata.keys()) == ['theme'] and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
os.remove(conf_path)
|
os.remove(conf_path)
|
||||||
|
continue
|
||||||
elif 'theme' in cdata and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
elif 'theme' in cdata and cdata['theme'] not in ['dark', 'light', 'system', 'defaultDark', 'defaultLight']:
|
||||||
cdata['theme'] = valid_electron_theme
|
cdata['theme'] = valid_electron_theme
|
||||||
|
modified = True
|
||||||
|
|
||||||
|
bounds = cdata.get('bounds', {})
|
||||||
|
if isinstance(bounds, dict) and (bounds.get('width', 0) < 1000 or bounds.get('height', 0) < 700):
|
||||||
|
cdata['bounds'] = {
|
||||||
|
'x': bounds.get('x', 50),
|
||||||
|
'y': bounds.get('y', 50),
|
||||||
|
'width': 1280,
|
||||||
|
'height': 800
|
||||||
|
}
|
||||||
|
modified = True
|
||||||
|
|
||||||
|
if modified:
|
||||||
with open(conf_path, 'w', encoding='utf-8') as f:
|
with open(conf_path, 'w', encoding='utf-8') as f:
|
||||||
json.dump(cdata, f, indent=2)
|
json.dump(cdata, f, indent=2)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user