Write Karabiner-Elements configuration in TypeScript.
[!NOTE] Use of TypeScript is optional. Config can also be written in JavaScript. Only the basics of JavaScript are needed. Check out my interactive course at codojo.dev.
karabiner.ts is heavily inspired by Goku. Compared to the edn format, it allows for:
And more features (abstractions) (hyperLayer, duoLayer, leaderMode, ...).
[!NOTE] Importing JSON to Karabiner-Elements is only needed when using the Online Editor.
karabiner.tswrites to~/.config/karabiner/karabiner.jsonif using with Node.js or Deno.Karabiner-Elements watches ~/.config/karabiner/karabiner.json and reloads it if updated.
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:
src/index.ts.npm run build.To update to the latest version, run npm run update (or npm update karabiner.ts).
npm install.Then write and build the config same as Option 1.
npm install karabiner.ts
(or install with yarn, pnpm, etc) then call writeToProfile() from any Node.js script in your preferred way.
In a Deno script file (replace {version}):
import { 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}
$ claude mcp add karabiner.ts \
-- python -m otcore.mcp_server <graph>