Skip to content

Commit

Permalink
feat!: allow running multiple kanata instances concurrently (#13)
Browse files Browse the repository at this point in the history
Contains multiple breaking changes. Config file was completely flipped.
  • Loading branch information
rszyma authored Mar 21, 2024
1 parent fd9a93a commit 48ae2a6
Show file tree
Hide file tree
Showing 14 changed files with 1,098 additions and 492 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist
dist
config*.toml
icons
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "."
}
]
}
83 changes: 52 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,73 @@ Works on Windows and Linux.

## Configuration

Default config will be autogenerated for you on the first run.
You can access it from from: `Click Tray Icon > Options`.
Default config file will be autogenerated for you on the first run.
You can access it from from: `Click Tray Icon > Configure`.
On Linux, the config folder location is `~/.config/kanata-tray`.
On Windows, it's `C:\Users\<YourUsername>\AppData\Roaming\kanata-tray`

### Examples

An example of customized configuration file:

```toml
# default: []
configurations = [
"~/.config/kanata/kanata.kbd",
"~/.config/kanata/test.kbd",
]

# default: []
executables = [
"~/.config/kanata/kanata",
"~/.config/kanata/kanata-debug",
]

[layer_icons]
base = "hello.ico"
qwerty = "qwerty.ico"
"*" = "other_layers.ico"
'$schema' = 'https://raw.githubusercontent.com/rszyma/kanata-tray/v0.2.0/doc/config_schema.json'

[general]
include_executables_from_system_path = false # default: true
include_configs_from_default_locations = false # default: true
launch_on_start = true # default: true
tcp_port = 5829 # default: 5829
allow_concurrent_presets = false

[defaults]
kanata_executable = '~/bin/kanata' # if empty or omitted, system $PATH will be searched.
kanata_config = '' # if empty or not omitted, kanata default config locations will be used.
tcp_port = 5829 # if not specified, defaults to 5829

[defaults.layer_icons]
mouse = 'mouse.png'
qwerty = 'qwerty.ico'
'*' = 'other_layers.ico'

[presets.'main cfg']
kanata_config = '~/.config/kanata/test.kbd'
autorun = true
# kanata_executable = ''
# layer_icons = { }
# tcp_port = 1234

[presets.'test cfg']
kanata_config = '~/.config/kanata/test.kbd'

```
### Explanation

`presets` - a config item, that adds an entry to tray menu. Each preset can have different settings for running kanata with:
`kanata_config`, `kanata_executable`, `autorun`, `layer_icons`, `tcp_port`.

Notes:
`preset.autorun` - when set to true, preset will run at kanata-tray startup.

`preset.layer_icons` - maps kanata layer names to custom icons. Custom icons should be placed in `icons` folder in config directory, next to `config.toml`. Accepted icon types on Linux are `.ico`, `.png`, `.jpg`; on Windows only `.ico` is supported. You can assign an icon to special identifier `'*'` to change icon for other layers not specified in `[layer_icons]`.

`defaults` - a config item, that allows to overwrite default values for all presets.
It accepts same configuration options that `presets` do.

`general.allow_concurrent_presets` - when enabled, allows running multiple presets at the same time.
When disabled, switching presets will stop currently running preset (if any).
Disabled by default.

Other notes:
- You can use `~` in paths to substitute to your "home" directory.
- `layer_icons` maps kanata layer names to custom icons. Custom icons should be placed in `icons` folder in config directory, next to `config.toml`. Accepted icon types on Linux are `.ico`, `.png`, `.jpg`; on Windows only `.ico` is supported. You can assign an icon to special identifier `"*"` to change icon for other layers not specified in `[layer_icons]`.
- On Windows, when providing paths, you need to replace every `\` character with `\\`. Example: `C:\\Users\\<User1\\Desktop\\kanata.kbd`.
- On Windows: make sure to surround paths with single-quotes `'` instead of double-quotes, otherwise paths will not work (because `\` would be treated as escape character).

Notes about autorun:
- If `configurations` is non-empty, the first item from it will be launched at start.
- Otherwise it falls back to a first kanata configs found by `include_configs_from_default_locations` option, if enabled.
- Otherwise, if no configs available, it won't auto-launch anything.
- Similar thing applies to kanata executables (see options `executables` and `include_executables_from_system_path`)
### Config completion in editors

In VSCode to get editor support for your kanata-tray config, install [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml#completion-and-validation-with-json-schema) extension and the following line at the top of your `config.toml` file.
```toml
"$schema" = "https://raw.githubusercontent.com/rszyma/kanata-tray/v0.2.0/doc/config_schema.json"
```
Make sure to replace version number in the schema link with whatever kanata-tray version you use.

## Supported Kanata Versions

Minimal supported version of kanata is the release after `v1.5.0`.
Minimal supported version of kanata is `v1.6.0`.

More specifically, builds after commit [010338b](https://github.com/jtroo/kanata/commit/010338b14d0020098b9263a615ef2152c249d666) (because it fixed an issue with TCP server)

Expand Down
Loading

0 comments on commit 48ae2a6

Please sign in to comment.