Screenshot-2024-11-29T11 45 50

Open karabiner-elements-profile-switcher in Script Kit

// Name: Karabiner Elements Profile Switcher
// Acknowledgements:
// - https://www.alfredforum.com/topic/9927-karabiner-elements-profile-switcher/
// Notes:
// - Probably could also work with cli https://github.com/raycast/extensions/blob/be03024b4c4f4f1ad0af7f4d20ea4630d7f0ee20/extensions/karabiner-profile-switcher/src/model/KarabinerManager.ts
import "@johnlindquist/kit"
import fs from 'fs'
const CONFIG_PATH = home('.config/karabiner/karabiner.json')
const configJson = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'))
const profileChoices = configJson.profiles.map((profile: any) => ({
name: profile.name,
value: profile.name,
tag: profile.selected ? '🟢' : '', // Note: Not sure if there's a better way to highlight currenly active
}))
const selectedProfile = await arg({
placeholder: 'Select a profile',
choices: profileChoices,
})
for (const profile of configJson.profiles) {
profile.selected = profile.name === selectedProfile // intentional mutation
}
fs.writeFileSync(CONFIG_PATH, JSON.stringify(configJson, null, 2))
notify(`Karabiner Elements profile switched to "${selectedProfile}"`)