Skip to content

DSL to author and import/export mappings #2269

Description

@ilonachan

Have you checked if an issue already exists for this feature request?

  • Nobody else has requested this feature before

What feature would you like added?

The goal is a simple (as possible) format for importing and exporting mappings and groups of mappings. The syntax can either be an officially defined schema for an existing data transfer format such as JSON or YAML, or a more specialized DSL.

  • This format should be human-readable, so it can be authored outside the app and later imported.
  • It should also be machine-writable, to allow generating mappings automatically based on definitions from arbitrary sources using simple scripting (the conversion itself is out of scope here).
  • And of course, Key Mapper should be able to produce a valid file of this type for any mapping or group of mappings, such that reimporting it on the same (or another*) device reproduces it identically.

* Certain identifiers and parameters for triggers or actions will likely be dependent on the device Key Mapper is running on, and/or some other physical input device. The handling of these cases should be clearly defined, even if unsupported. Ideally unspecified references could be resolved during the import process, e.g. by giving each a name and letting the importing user manually specify it.

Rough specification

The exact requirements for this language will need to reflect the current feature set of Key Mapper's UI, and the addition of new features should probably be tracked with a version identifier in scripts. See particularly #988 for details.

First attempt to collect a set of requirements (subject to change):

  • All types of triggers & sequences can be modeled
  • All types of actions with parameters
  • All types of constraints with parameters
    • Logical constraint groups
  • Metadata
    • Unique mapping ID? Human-readable name?
  • Groups and subgroups of mappings
    • In a single file for convenience?
    • Format for importing group setups from archive file structure?
  • Versionable format, suggestions:
    • Specify app version: allowed feature set
    • Specify script version: syntax improvements
    • Migrating older scripts automatically?

Previous work

I'm unsure if a suitably similar format already exists. The first instinctual connection "AutoHotKey" uses a DSL specifically tailored for keystrokes (while Key Mapper supports many other trigger types) and with full scripting functionality (out of scope for this). Inspiration could still be taken from the syntax to define Hotkeys.

On the other hand, the XCompose format is simple and declarative, but likewise tailored to keyboard use and without support for complex actions or conditions.

App version

4.5.0-foss 271

Device model and manufacturer

as agnostic as possible

Extra info

  • My device is rooted

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions