- Must load key binds from a file
- Must be able to execute shell commands as shortcut commands
- Provide a key map interface, where actions are described by a ‘string’ or series of key presses
- Must work on X Server on Linux
- Commands must no be invoked without user’s intent
- User must be able to quit and/or cancel shortcut attempt without executing any action
- User must be able to invoke commands from anywhere in the system
- All commands must have a unique key string
- Must detect non-unique key strings on key map import
- Must warn user about non-unique key strings
- Must indicate which key strings are conflicting, or non-unique
- When entering key strings, key strings must not be detected by other applications
If you are confused, checkout Spacemacs’ shortcut system. It is basically what I want to emulate system wide.
- Decouple the input such that it is easier to port to other systems
- Allow for
sudo
commands - Show a UI only when accepting key strings
- Must provide a way to reload key map without restarting the application
- Must respond to key presses/commands within 0.5 second
- Store key string in file with the format
"key-string" command
wherekey-string
is some key string such asaee
, this represents typinga
thene
thene
, surrounded by""
andcommand
is some shell command to be executed. - Will require some data type to keep track of keymap in memory.
Perhaps some sort of tree to store key map
- Primary Actor: User
- Supporting Actors: OS
- Preconditions: Launching on XServer
- Trigger: Program execution, launching the program
- Main Scenario:
- User starts the software
- Load Key Map, see Load Key Map for behaviour
- Continue running in the background
- Watch for master shortcut
- Primary Actor: Software/System
- Supporting Actors: OS
- Preconditions:
- The software is running
- A file path is provided
- The software is allowed to read and write the given file path
- Trigger: Program execution, or reloading key map(User generated event)
- Main Scenario:
- Open and read file at given file path
- Read data in the file to build the key map tree
- Close file
- Secondary Scenarios:
- 1.1 File does not exist
- Write to log message about conflicting file
- Use default key strings and commands
- 2.1 There are conflicting key strings
- Do not load conflicting key strings and unload any that are already loaded and registered
- Write to log conflicting key strings
- Message should contain the conflicting key strings and the commands associated with the key strings
- Continue loading key strings
- 2.2 The data is in an unsupported format
- Print the line number where the parse error happened
- Continue parsing next line
- 1.1 File does not exist
- Primary Actor: User
- Supporting Actors: OS, XServer
- Preconditions: Program is running, Start key is defined
- Trigger: The user presses predefined shortcut
- Main Scenario:
- Grab keyboard from system
- Listen for any key presses, see Enter Key press
- Primary Actor: User
- Supporting Actors: OS/ XServer
- Preconditions: The program is running, start key string is entered
- Trigger: The user presses a key on the keyboard
- Main Scenario:
- User presses key
- Key is compared with currently available key presses options in the string
- Execute available command
- Listen for next key press
- Secondary Scenarios:
- Primary Actor: User
- Supporting Actors: OS, XServer
- Preconditions: The program is running, start key string is entered
- Trigger: Pressed cancel key, predefined
- Main Scenario:
- Stop listening to key presses
- Release the keyboard back to the system
- Primary Actor: User
- Supporting Actors: OS, XServer
- Preconditions:
- Trigger:
- Main Scenario:
An UML diagram is not necessary for this project, it doesn’t rely much on OOP. But I needed a way to represent the tree key map tree, so this exists.