feat(app-binding): lier les presets aux applications
Ajoute la configuration des associations application/preset, le service de suivi du focus, l'intégration GUI et les fichiers d'installation nécessaires. Ajoute les tests unitaires ciblés des bindings, du service de focus, des migrations et des composants GUI associés. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -98,6 +98,9 @@ class Migrations:
|
||||
if v < version.parse("1.6.0-beta"):
|
||||
self._convert_to_individual_mappings()
|
||||
|
||||
if v < version.parse("2.3.0"):
|
||||
self._add_app_binding_config()
|
||||
|
||||
# add new migrations here
|
||||
|
||||
if v < version.parse(VERSION):
|
||||
@ -212,6 +215,35 @@ class Migrations:
|
||||
logger.info('Updating version in config to "%s"', VERSION)
|
||||
json.dump(config, file, indent=4)
|
||||
|
||||
def _add_app_binding_config(self):
|
||||
"""Add the focus-driven app-binding keys to config.json if missing.
|
||||
|
||||
This is an additive, backwards-compatible change: presets and autoload
|
||||
configuration are left untouched.
|
||||
"""
|
||||
config_file = os.path.join(PathUtils.config_path(), "config.json")
|
||||
if not os.path.exists(config_file):
|
||||
return
|
||||
|
||||
with open(config_file, "r") as file:
|
||||
config = json.load(file)
|
||||
|
||||
changed = False
|
||||
if "app_binding_enabled" not in config:
|
||||
config["app_binding_enabled"] = False
|
||||
changed = True
|
||||
if "app_bindings" not in config:
|
||||
config["app_bindings"] = []
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
return
|
||||
|
||||
with open(config_file, "w") as file:
|
||||
logger.info("Adding app-binding defaults to config")
|
||||
json.dump(config, file, indent=4)
|
||||
file.write("\n")
|
||||
|
||||
def _rename_to_input_remapper(self):
|
||||
"""Rename .config/key-mapper to .config/input-remapper."""
|
||||
old_config_path = os.path.join(UserUtils.home, ".config/key-mapper")
|
||||
|
||||
Reference in New Issue
Block a user