Created
February 12, 2025 20:58
-
-
Save tayiorbeii/72395075ef266c6b5815c5f924c79e3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Superwhisper Mode Selector | |
// Author: Taylor Bell | |
import "@johnlindquist/kit"; | |
import { Choice } from "@johnlindquist/kit"; | |
import { readFile } from "node:fs/promises"; | |
const modesDir = home("Documents", "superwhisper", "modes"); | |
try { | |
const files = await readdir(modesDir); | |
const choices: Choice[] = []; | |
for (const file of files) { | |
if (file.endsWith(".json")) { | |
const filePath = path.join(modesDir, file); | |
try { | |
const content = await readFile(filePath, "utf8"); | |
const mode = JSON.parse(content); | |
choices.push({ | |
name: mode.name, | |
value: mode.key, | |
}); | |
} catch (parseError) { | |
console.error(`Error parsing JSON file ${file}:`, parseError); | |
continue; | |
} | |
} | |
} | |
const selectedMode = await arg("Select a mode", choices); | |
await open(`superwhisper://mode?key=${selectedMode}`); | |
} catch (readDirError) { | |
console.error(`Error reading modes directory:`, readDirError); | |
exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment