Open shortcuts in Script Kit

// Name: Shortcuts
// Description: Shortcut Launcher
// Keyword: sc
import "@johnlindquist/kit";
const DB = home("Library", "Shortcuts", "Shortcuts.sqlite");
let { default: sqlite3 } = await import("sqlite3");
let { open } = await import("sqlite");
const shortcuts_db = await open({ filename: DB, driver: sqlite3.Database });
let query = await shortcuts_db.all(
"SELECT ZNAME,ZACTIONSDESCRIPTION,ZICON,ZBACKGROUNDCOLORVALUE,ZGLYPHNUMBER FROM ZSHORTCUT INNER JOIN ZSHORTCUTICON on ZSHORTCUTICON.Z_PK=ZICON"
);
//Color mappings found https://github.com/atnbueno/Shortcuts-old
const colors = {
4282601983: { RGB: "#F26369", Gradient: "#F36F74 #F2585E" },
4251333119: { RGB: "#FF8567", Gradient: "#FF8E73 #FF7C5C" },
4271458815: { RGB: "#F7A752", Gradient: "#F8AE5F #F7A145" },
4274264319: { RGB: "#E7C640", Gradient: "#E8CA45 #E5C238" },
4292093695: { RGB: "#45C95F", Gradient: "#53CD6B #37C553" },
431817727: { RGB: "#49CBAE", Gradient: "#57CFB4 #2AC7A8" },
1440408063: { RGB: "#51C8DC", Gradient: "#5ACCDE #3FC4D9" },
463140863: { RGB: "#12B4F6", Gradient: "#24BAF7 #00AFF6" },
946986751: { RGB: "#4A69C6", Gradient: "#5874CA #3D5EC2" },
2071128575: { RGB: "#8857C2", Gradient: "#9164C7 #7F4BBE" },
3679049983: { RGB: "#BB7BE4", Gradient: "#C085E6 #B671E2" },
3980825855: { RGB: "#F58BD5", Gradient: "#F694D8 #F583D2" },
255: { RGB: "#87919B", Gradient: "#9099A3 #7E8994" },
3031607807: { RGB: "#95A095", Gradient: "#9DA79D #8D998E" },
2846468607: { RGB: "#9D918C", Gradient: "#A49995 #968984" },
};
// Glyphs names found https://github.com/atnbueno/Shortcuts-old, ChatGPT used to generate emojis
const glyphs = {
59452: "๐Ÿš—",
61446: "๐Ÿš—",
61447: "๐Ÿš—",
59678: "๐ŸšŒ",
61448: "๐ŸšŒ",
61449: "๐Ÿš‹",
61450: "๐Ÿš‡",
59668: "๐Ÿšฒ",
59652: "๐Ÿš‘",
59648: "โœˆ๏ธ",
59755: "๐Ÿ ",
59677: "๐Ÿข",
59828: "๐Ÿ›’",
61553: "๐Ÿ›๏ธ",
59750: "๐Ÿ‘œ",
59863: "๐Ÿด",
59741: "โ›ฝ",
59854: "๐ŸŒก๏ธ",
59845: "โ˜€๏ธ",
59782: "๐ŸŒ™",
61517: "๐ŸŒ•",
59835: "โ„๏ธ",
59714: "โ˜๏ธ",
59715: "๐ŸŒง๏ธ",
59861: "โ˜‚๏ธ",
59734: "๐Ÿ”ฅ",
59669: "๐Ÿ”ญ",
59717: "๐Ÿงญ",
59412: "๐ŸŒ",
59784: "๐Ÿž๏ธ",
59733: "๐ŸŽž๏ธ",
59682: "๐Ÿ“ท",
59402: "๐ŸŽฅ",
59780: "๐ŸŽค",
59864: "๐Ÿ“น",
59711: "๐Ÿ“‹",
59681: "๐Ÿ“†",
59414: "๐Ÿ’ฌ",
59403: "๐Ÿ’ฌ๐Ÿ’ฌ",
59779: "๐Ÿ’ฌ",
59773: "๐Ÿ’Œ",
59774: "๐Ÿ“ฌ",
59836: "โœˆ๏ธ",
61462: "๐ŸŒ",
59676: "๐Ÿ’ผ",
61570: "๐Ÿ“‚",
61571: "๐Ÿ“‚โš™๏ธ",
59719: "๐Ÿ’ณ",
59865: "โŒš",
59814: "๐Ÿ“ž",
59436: "๐Ÿ’ป",
59446: "โŒจ๏ธ",
59680: "๐Ÿงฎ",
59662: "๐Ÿ“Š",
59817: "๐Ÿ–จ๏ธ",
59752: "๐Ÿ’ฝ",
59722: "๐Ÿ–ฅ๏ธ",
59519: "๐Ÿ“ฆ",
59826: "๐Ÿ—„๏ธ",
59653: "๐Ÿ“š",
59721: "๐ŸงŠ",
59851: "๐Ÿ“บ",
59742: "๐ŸŽฎ",
59818: "๐Ÿงฉ",
61552: "๐Ÿงฉ",
59753: "๐ŸŽง",
61479: "๐Ÿ”˜",
61481: "๐Ÿฆป",
59790: "๐ŸŽต",
59839: "๐Ÿ”Š",
61470: "๐Ÿ”Š",
61471: "๐Ÿ”Š",
61472: "๐Ÿ”‡",
61473: "๐Ÿ”Š",
61478: "๐Ÿ”Š",
61474: "๐Ÿ”Š",
59671: "๐Ÿ“š",
59465: "๐Ÿ“–",
61442: "๐Ÿ“•",
59745: "๐Ÿ‘“",
59788: "๐ŸŽซ",
59730: "๐ŸŽญ",
59723: "๐ŸŽฒ",
59663: "โšพ",
59664: "๐Ÿ€",
59837: "โšฝ",
59456: "๐Ÿˆ",
59762: "๐Ÿ›ถ",
59756: "๐ŸŽ",
59712: "๐Ÿ•ฐ๏ธ",
59649: "โฐ",
59844: "โฑ๏ธ",
59667: "๐Ÿ””",
59754: "โค๏ธ",
61577: "โค๏ธ",
61578: "โค๏ธโค๏ธ",
59841: "โญ",
61579: "โญ",
61581: "โœจ",
59763: "๐Ÿ’ก",
59764: "โšก",
59736: "๐Ÿšฉ",
59848: "๐Ÿท๏ธ",
59760: "๐Ÿ”‘",
59757: "โŒ›",
59770: "๐Ÿ”’",
59862: "๐Ÿ”“",
59489: "๐Ÿ”‹",
59511: "โœจ",
59771: "๐Ÿช„",
59793: "๐Ÿ–Œ๏ธ",
59798: "โœ๏ธ",
59794: "๐Ÿ“Ž",
59824: "โœ‚๏ธ",
59772: "๐Ÿ”",
59685: "๐Ÿ”—",
59716: "๐ŸŽจ",
59748: "๐Ÿ”จ",
59870: "๐Ÿ”ง",
59743: "โš™๏ธ",
59825: "๐Ÿช›",
59859: "๐Ÿ—‘๏ธ",
59866: "๐Ÿ’ง",
59789: "โ˜•",
59827: "๐Ÿ‘•",
59815: "๐Ÿ’Š",
59660: "๐Ÿฉน",
59843: "๐Ÿฉบ",
61551: "๐Ÿ˜ท",
59657: "โš›๏ธ",
59684: "๐Ÿฑ",
59728: "๐Ÿถ",
61554: "๐Ÿป",
61555: "๐Ÿฏ",
61556: "๐Ÿต",
61557: "๐Ÿ",
61558: "๐Ÿ‡",
61559: "๐Ÿ",
61560: "๐Ÿ”",
61561: "๐Ÿ–",
61562: "๐Ÿญ",
61563: "๐Ÿ„",
61564: "๐Ÿ‰",
59651: "๐Ÿ‘ฝ",
61565: "๐Ÿ‘พ",
61566: "๐Ÿค–",
61567: "๐Ÿ‘ป",
61568: "๐Ÿ’ฉ",
61569: "๐Ÿ’€",
59796: "๐Ÿพ",
59746: "๐ŸŽ“",
59744: "๐ŸŽ",
59666: "๐Ÿ›๏ธ",
59822: "๐Ÿš€",
61444: "๐Ÿ—บ๏ธ",
61452: "๐Ÿ“",
61453: "๐Ÿšฆ",
61454: "๐ŸŒก๏ธ",
61455: "๐ŸŒ",
61456: "๐Ÿ“š",
61573: "๐Ÿ“š",
61574: "๐Ÿ“š",
61576: "๐Ÿ“š",
61457: "๐Ÿ“š",
61458: "๐Ÿ“š",
61459: "๐Ÿ“š",
61460: "๐Ÿ“ท",
61461: "๐Ÿ“",
61464: "๐Ÿ“",
61465: "๐Ÿ“",
61466: "๐Ÿ“",
61582: "๐Ÿ’ฌ",
61468: "๐Ÿ’ฌ",
61475: "๐ŸŽง",
61476: "๐ŸŽง",
61477: "๐ŸŽง",
61480: "๐Ÿ“ป",
61482: "๐Ÿ“บ",
61483: "๐Ÿ”Š",
61484: "๐ŸŒŠ",
61486: "๐Ÿ“ฑ",
61487: "๐Ÿ“ฑ",
61488: "๐Ÿ“ฑ",
61489: "๐Ÿ“ฑ",
61490: "๐Ÿ“ฑ",
61491: "๐Ÿ“ฑ",
59806: "โ™ฟ",
59801: "๐Ÿšถ",
59800: "๐Ÿšถโ€โ™‚๏ธ๐Ÿšถโ€โ™€๏ธ",
59799: "๐Ÿšถโ€โ™‚๏ธ๐Ÿšถโ€โ™€๏ธ๐Ÿšถโ€โ™‚๏ธ",
59437: "๐Ÿšถ",
59812: "๐Ÿšถโ€โ™‚๏ธ",
59808: "๐Ÿƒ",
61493: "๐Ÿƒ",
61494: "๐Ÿƒ",
61495: "๐ŸŽง",
61496: "๐Ÿ”",
61532: "๐Ÿง ",
61533: "๐Ÿง ",
61534: "๐Ÿ˜€",
61535: "๐Ÿ˜„",
61536: "๐Ÿ˜†",
61537: "๐Ÿ˜‚",
61538: "๐Ÿคฃ",
61539: "๐Ÿ˜œ",
61540: "๐Ÿ˜ฌ",
61541: "๐Ÿ˜",
61542: "๐Ÿ˜˜",
61543: "๐Ÿ˜Š",
61544: "๐Ÿ˜Ž",
61545: "๐Ÿ˜",
61546: "๐Ÿค–",
59751: "๐Ÿ–๏ธ",
61585: "๐Ÿ–๏ธ",
59857: "๐Ÿ‘",
61547: "๐Ÿ‘",
61548: "โœŒ๏ธ",
61549: "๐ŸคŸ",
61550: "๐Ÿ‘Š",
61440: "๐Ÿ“ฒ",
59650: "โš ๏ธ",
59654: "โ†ฉ๏ธ",
59655: "โ†ช๏ธ",
59670: "๐Ÿ”–",
59661: "๐Ÿ“ฆ",
59819: "๐Ÿ“ฐ",
59508: "โ–ถ๏ธ",
59674: "๐Ÿ“ฆ",
59675: "๐Ÿ”ต",
59696: "โ†ฉ๏ธ",
59705: "โ†ช๏ธ",
59693: "โฌ‡๏ธ",
59707: "โฌ†๏ธ",
59692: "โฌ‡๏ธ",
59708: "โฌ†๏ธ",
59699: "โ–ถ๏ธ",
59704: "โช",
59702: "โธ๏ธ",
59706: "โน๏ธ",
59695: "โญ๏ธ",
59703: "โ“",
59690: "โœ”๏ธ",
59700: "โž•",
59697: "๐Ÿ”ค",
59834: "๐Ÿ˜Š",
61589: "โŒ",
59725: "๐Ÿ“„",
59395: "๐Ÿ’ฒ",
59448: "๐Ÿ’ถ",
59512: "ยฃ",
59514: "ยฅ",
59515: "โ‚ฟ",
59709: "โŒ",
59656: "*๏ธโƒฃ",
59727: "๐Ÿ“„",
59791: "๐Ÿ“ฐ",
59739: "๐Ÿ”ฒ",
59392: "โ€ฆ",
59445: "๐Ÿ“‹",
61587: "โœ…",
59405: "๐Ÿ”ฒ๐Ÿ”ฒ",
59758: "โ™พ๏ธ",
59820: "โ™ป๏ธ",
59767: "๐Ÿ”„",
59849: "๐ŸŽฏ",
59816: "๐ŸŽ™๏ธ",
59768: "๐Ÿ“",
59769: "๐Ÿ“Œ",
59795: "๐Ÿ…ฟ๏ธ",
59720: "๐ŸŒพ",
59830: "โฌ†๏ธโฌ‡๏ธ",
59786: "โ†–๏ธโ†˜๏ธ",
59821: "๐Ÿ”„",
59846: "๐Ÿ”„",
59832: "๐Ÿ”€",
59833: "๐ŸŽš๏ธ",
61583: "๐Ÿ’ฌ",
59797: "โœŒ๏ธ",
59856: "๐ŸŸก",
59853: "๐Ÿ†Ž",
61588: "๐Ÿ“ฆ",
59459: "โ˜๏ธโ˜๏ธ",
59461: "๐Ÿ’Š",
59732: "๐Ÿ“ฐ",
59497: "๐Ÿ“ฐ",
59867: "๐Ÿ“ถ",
61501: "๐Ÿ“ฒ",
61497: "๐Ÿšฅ",
61498: "๐Ÿšฅ",
61499: "๐Ÿ“ถ",
61500: "๐Ÿ“ถ",
61502: "๐ŸŽต",
61503: "๐ŸŽต",
61504: "๐ŸŽต",
61505: "๐ŸŽต",
61506: "๐ŸŽต",
61507: "๐ŸŽต",
61508: "๐ŸŽต",
61509: "๐ŸŽต",
61510: "๐Ÿ“…",
61511: "๐Ÿ“…",
61512: "โฒ๏ธ",
61513: "โฒ๏ธ",
61514: "๐Ÿ“",
61515: "๐Ÿ“",
61518: "๐ŸŒž",
61519: "๐Ÿ’ก",
61520: "โฌ",
61521: "โซ",
61522: "๐Ÿ“ท",
61523: "๐Ÿ“ท",
61524: "๐Ÿ’ผ",
61525: "๐ŸŒ…",
61528: "๐Ÿšซ",
61529: "๐Ÿ”˜",
61530: "โญ•",
61531: "๐Ÿ”ฒ",
59781: "โœ๏ธ",
};
let shortcuts = query.map((shortcut) => {
let glyph = glyphs[shortcut.ZGLYPHNUMBER];
let name = shortcut.ZNAME;
let value = shortcut.ZNAME;
let html = `<div class="flex flex-row h-full w-full">
<svg width=48 height=48 class="h-full" style="background-color:${
colors[shortcut.ZBACKGROUNDCOLORVALUE]?.RGB
}"><text x=12 y=36 font-size=24>${glyph}</text></svg>
<div class="flex-1 flex flex-row items-center px-2">${name}</div>
</div>`;
return { name, value, html };
});
let flags = {
view: {
name: "View in Shortcuts",
},
run: {
name: "Run Shortcut",
},
};
let shortcut = await arg(
{ prompt: "Which shortcut would you like to run?", flags },
shortcuts
);
await hide();
if (flag?.view) {
await exec(`/usr/bin/shortcuts view "${shortcut.trim()}"`);
} else {
let result = await exec(`/usr/bin/shortcuts run "${shortcut.trim()}" &`);
if (result?.stdout) await div(md(`## Output:\n\n${result.stdout}`));
}