Config()
User configuration of Karabiner-Elements.
Classes
Members
currentProfile object
The current profile object.
data object
Config data
io IO
IO object for reading/writing this config from/to a file.
Methods
clearRules() → Config
Clears all the rules in the current profile.
Returns:
Itself
- Type:
- Config
load() → Config
Loads data from the config file.
Returns:
Itself
- Type:
- Config
loadJSON(data) → Config
Loads JSON data.
Parameters:
Name | Type | Description |
---|---|---|
data
|
|
JSON string or object |
Returns:
Itself
- Type:
- Config
out()
Outputs JSON representation of this config to STDOUT.
save() → Config
Writes the current data on the config file.
Returns:
Itself
- Type:
- Config
selectProfile(prof) → Config
Switches to the specified profile.
Parameters:
Name | Type | Description |
---|---|---|
prof
|
|
Profile index, name, or regex for name |
Returns:
Itself
- Type:
- Config
setIO(fileopt, optsopt) → Config
Setup IO
object for reading/writing this config from/to a file.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
file opt
|
string |
'~/.config/karabiner/karabiner.json'
|
Config file path |
opts opt
|
object | IO options |
Returns:
Itself
- Type:
- Config
setRules(rules) → Config
Sets the given rules to the current profile.
Parameters:
Name | Type | Description |
---|---|---|
rules
|
|
An array of rule definitions |
Returns:
Itself
- Type:
- Config
toJSON(stringifyopt) → objectstring
Returns a JSON representation of this config.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
stringify opt
|
boolean |
false
|
If |
Returns:
A JSON object
- Type:
-
- object
- string
staticfromFile(file, optsopt) → Config
Instantiates Config from a JSON file.
Config file is normally located at ~/.config/karabiner/karabiner.json
Parameters:
Name | Type | Description |
---|---|---|
file
|
string | JSON file path |
opts opt
|
object | IO options |
Returns:
New instance
- Type:
- Config
staticfromJSON(data) → Config
Instantiates Config from a JSON string or object.
Parameters:
Name | Type | Description |
---|---|---|
data
|
|
JSON string or object |
Returns:
New instance
- Type:
- Config