Created
December 30, 2025 11:31
-
-
Save 5w14/df928e32c08309a82571a708219ffbf8 to your computer and use it in GitHub Desktop.
bun js script to get a online minecraft launch string from prismlauncher on linux
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
| #!/usr/bin/env bun | |
| import fs from 'fs'; | |
| const args = [...process.argv].splice(2); | |
| let filter = (username: string) => true; | |
| if (args.length > 0) { | |
| filter = (username: string) => username.toLowerCase().startsWith(args[0].toLowerCase()); | |
| } | |
| const accounts = JSON.parse(fs.readFileSync(`${Bun.env.HOME}/.local/share/PrismLauncher/accounts.json`).toString()); | |
| const profile = accounts.accounts.filter(v => filter(v.profile.name))[0]; | |
| if (!profile) { | |
| console.error("Could not find profile! Available accounts: " + accounts.accounts.map(v => v.profile.name).join(', ')); | |
| process.exit(1); | |
| } | |
| const cstr = `--accessToken "${profile.ygg.token}" --username ${profile.profile.name} --userType msa`; | |
| const proc = Bun.spawn(["wl-copy"], { | |
| stdin: "pipe", | |
| stdout: "ignore", | |
| stderr: "inherit", | |
| }); | |
| proc.stdin.write(cstr); | |
| proc.stdin.end(); | |
| const code = await proc.exited; | |
| if (code !== 0) throw new Error(`wl-copy exited with code ${code}`); | |
| console.log("Copied args to launch mc as " + profile.profile.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment