Config()

User configuration of Karabiner-Elements.

Constructor

new Config()

Source:
Config.js, line 11

Classes

Config

Members

currentProfile object

The current profile object.

Source:
Config.js, line 97

data object

Config data

Source:
Config.js, line 35

io IO

IO object for reading/writing this config from/to a file.

Source:
Config.js, line 40

Methods

clearRules()Config

Clears all the rules in the current profile.

Source:
Config.js, line 148
Returns:

Itself

Type:
Config

load()Config

Loads data from the config file.

Source:
Config.js, line 80
Returns:

Itself

Type:
Config

loadJSON(data)Config

Loads JSON data.

Parameters:
Name Type Description
data
  • string
  • object

JSON string or object

Source:
Config.js, line 72
Returns:

Itself

Type:
Config

out()

Outputs JSON representation of this config to STDOUT.

Source:
Config.js, line 54

save()Config

Writes the current data on the config file.

Source:
Config.js, line 88
Returns:

Itself

Type:
Config

selectProfile(prof)Config

Switches to the specified profile.

Parameters:
Name Type Description
prof
  • number
  • string
  • RegExp

Profile index, name, or regex for name

Source:
Config.js, line 111
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
fileopt string '~/.config/karabiner/karabiner.json'

Config file path

optsopt object

IO options

Source:
Config.js, line 63
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

Source:
Config.js, line 156
Returns:

Itself

Type:
Config

toJSON(stringifyopt)objectstring

Returns a JSON representation of this config.

Parameters:
Name Type Default Description
stringifyopt boolean false

If true, returns a stringified result

Source:
Config.js, line 47
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

optsopt object

IO options

Source:
Config.js, line 27
Returns:

New instance

Type:
Config

staticfromJSON(data)Config

Instantiates Config from a JSON string or object.

Parameters:
Name Type Description
data
  • string
  • object

JSON string or object

Source:
Config.js, line 17
Returns:

New instance

Type:
Config