Scripts by gm90

Kill Notification

Inspired by Tyler Hall, a quick shortcut key to clear a mac notification with the awkward Big Sur UX with the tiny cross click area.

// Shortcut: command option k
// Menu: Kill Notification
// Description: Kill pesky mac os notification inspired by 240px-invisible-pixels @ https://tyler.io/240-invisible-pixels/
// Author: Gary McCann
const robot = await npm ("robotjs");
const screenSize = robot.getScreenSize();
const xPosition = screenSize.width - 354;
const yPosition = 47;
robot.moveMouse(xPosition, yPosition);
setTimeout(() => {
robot.mouseClick();
}, 100)
Discuss Post

HEIC Converter

Loving Kit! ❤️ Awesome work @johnlindquist 🔥

The simplicity of Airdrop between Apple devices is great until your image turns up in a file format that most file uploads still don't support. Used to spend a few mins opening up preview and re-exporting. So wrote this little script to do the heavy lifting.

// Menu: HEIC Converter
// Description: Convert the currently selected HEIC file to either JPEG or PNG
// Author: Gary McCann
const { getSelectedFile } = await kit("file");
const { promises: fs } = await npm("fs");
const path = await npm("path");
const convert = await npm("heic-convert");
const imagePath = await getSelectedFile();
const { dir, name: imageName, ext } = path.parse(imagePath);
const format = await arg(
"Which format would you like to convert to:",
async () => {
let options = ["JPEG", "PNG"];
return options.map((format) => {
return {
name: format,
value: format,
};
});
}
);
const buffer = await fs.readFile(imagePath);
const outputBuffer = await convert({
buffer,
format,
quality: 1,
});
const updatedFilePath = `${dir}/${imageName}.${format}`;
await fs.writeFile(updatedFilePath, outputBuffer);

Few bits to add:

  1. Validation to make sure a HEIC file is selected.
  2. Would like to maybe show some sort of progress bar, whilst its doing its business.
Discuss Post