Skip to content

ourongxing/karabiner.ts

 
 

Repository files navigation

karabiner.ts

License Coverage Status Wallaby.js npm deno module

Write Karabiner-Elements configuration in TypeScript.

Why karabiner.ts

karabiner.ts is heavily inspired by Goku. Compared to the edn format, it allows for:

  • Easier-to-understand TypeScript/JavaScript syntax
  • Strong-typed abstractions and key aliases with IDE support
  • Structured config files instead of one big file

Learn More

Using the Online Editor

  1. Write config in the online editor. (Optional: fork the editor to save the config for later editing)
  2. Copy the generated JSON then add to Karabiner-Elements.

Using Node.js

npm

Option 1

npx create-karabiner-config@latest

The default directory name is karabiner-config. You can pass another project-name:

npx create-karabiner-config@latest [project-name]

Then:

  1. Write your key mapping in src/index.ts.
  2. Set the profile name. Create a new Karabiner-Elements profile if needed.
  3. Run npm run build.

To update to the latest version, run npm run update (or npm update karabiner.ts).

Option 2

  1. Download (or clone | fork) the examples/starter repo.
  2. Run npm install.

Then write and build the config same as Option 1.

Option 3

npm install karabiner.ts

(or install with yarn, pnpm, etc) then call writeToProfile() from any Node.js script in your preferred way.

Using Deno

deno module

In a Deno script file (replace {version}):

import { rule, writeToProfile } from 'https://deno.land/x/karabinerts@{version}/deno.ts'

writeToProfile('Default', [
  // rule(...
])

Then run it with:

deno run --allow-env --allow-read --allow-write {filename}

About

Write Karabiner-Elements configuration in TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.8%
  • JavaScript 1.5%
  • Other 0.7%