mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
* chore(i18n): translate every missing string in all locales Adds the 87 strings the bottom-screen Dashboard and in-game stats pages introduced to all 32 locales, plus the 51 older settings strings Japanese and the 50 Chinese locales were still missing. Every locale now has all 3456 translatable strings with the same placeholders as English. Also translates 36 entries that were still English where the language does not use the English word, and makes es-419 touch_app_id use the same %1$s placeholder as English. * chore(patches): drop comments from the lines downstream patches add Removes comment lines and trailing comments from lines our patches add, with hunk headers recounted. Lines that a later patch uses as context and the upstream backport 0123 are left as they are. The gamescope, FEX, proot and xodus series still apply to their pinned sources, and the patched trees differ only in those comments. test_hud_frames now finds the HUD writer by its first declaration. * docs: credit Greenlight, Better xCloud, viture-v2, GameNative and DiRTTelemetryErrorFix These were credited only in source headers and NOTICE files. * chore: remove source comments and unused functions Removes explanatory comments from first-party Kotlin, Java, C, C++, Rust, TypeScript, Python, shell, Gradle, CMake and workflow files. License and attribution headers stay, and vendored third-party trees, generated files and license files are untouched. A shellcheck directive is kept, and udevmon's fallthrough comments became fallthrough attributes. Syntax trees and token streams match the previous sources apart from the comments and Python docstrings. Module docstrings that argparse prints are kept, and device-smoke.sh prints the same --help text from a heredoc. Also removes 37 functions and 4 fields that nothing referenced. * chore: remove comments from the Syncthing integration and the latest main sources * docs: credit Syncthing and the syncthing-android fork * chore(i18n): translate the Syncthing strings in all locales The 107 strings the Syncthing integration added are now in all 32 locales. sync_web_path_locked names the Syncthing tab by its label. * docs: credit @xXJSONDeruloXx for the HUD metric readers The CPU, GPU load, thermal and battery readers come from their PerformanceHudView pull requests #777, #877, #991, #1406 and #1573. The FusionHUD credit line is unchanged. * docs: credit the HUD metric readers to @xXJSONDeruloXx's work
80 lines
2.9 KiB
Python
80 lines
2.9 KiB
Python
#!/usr/bin/python3
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
OVERRIDES = {'enableLinuxVulkanAsync': True, 'motionSmoothing': False}
|
|
|
|
|
|
def read(path):
|
|
try:
|
|
with path.open() as source:
|
|
settings = json.load(source)
|
|
except FileNotFoundError:
|
|
return {}
|
|
if not isinstance(settings, dict) or not isinstance(settings.get('steamvr', {}), dict):
|
|
raise ValueError('Invalid SteamVR settings object')
|
|
return settings
|
|
|
|
|
|
def write(path, value):
|
|
path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
temporary = path.with_name(path.name + '.tmp')
|
|
with os.fdopen(os.open(temporary, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o600), 'w') as destination:
|
|
json.dump(value, destination, indent=3)
|
|
destination.write('\n')
|
|
os.replace(temporary, path)
|
|
|
|
|
|
def saved_preferences(path):
|
|
try:
|
|
backup = read(path)
|
|
if not isinstance(backup.get('section'), bool) or not isinstance(backup.get('values'), dict):
|
|
raise ValueError('invalid backup object')
|
|
for key in OVERRIDES:
|
|
entry = backup['values'].get(key)
|
|
if not isinstance(entry, list) or len(entry) != 2 or not isinstance(entry[0], bool):
|
|
raise ValueError('invalid saved preference: ' + key)
|
|
return backup
|
|
except ValueError as error:
|
|
raise ValueError(f'Invalid preference backup {path}; repair the saved section/values and retry restore. '
|
|
'The backup and current preferences have been preserved.') from error
|
|
|
|
|
|
def update(operation, settings_path, backup_path):
|
|
settings = read(settings_path)
|
|
if operation == 'apply':
|
|
if backup_path.exists():
|
|
saved_preferences(backup_path)
|
|
else:
|
|
section = settings.get('steamvr', {})
|
|
write(backup_path, {'section': 'steamvr' in settings,
|
|
'values': {key: [key in section, section.get(key)] for key in OVERRIDES}})
|
|
settings.setdefault('steamvr', {}).update(OVERRIDES)
|
|
write(settings_path, settings)
|
|
elif operation == 'restore':
|
|
if not backup_path.exists():
|
|
return
|
|
backup = saved_preferences(backup_path)
|
|
section = settings.setdefault('steamvr', {})
|
|
for key in OVERRIDES:
|
|
present, value = backup['values'][key]
|
|
if present:
|
|
section[key] = value
|
|
else:
|
|
section.pop(key, None)
|
|
if not section and not backup['section']:
|
|
settings.pop('steamvr')
|
|
write(settings_path, settings)
|
|
backup_path.unlink()
|
|
else:
|
|
raise ValueError('Expected apply or restore')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
update(sys.argv[1], Path(sys.argv[2]), Path(sys.argv[3]))
|
|
except (OSError, ValueError, KeyError, IndexError, TypeError) as error:
|
|
sys.exit('Could not update SteamVR settings: ' + str(error))
|