Open shortcuts in Script Kit
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"
);
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" },
};
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}`));
}