Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created October 26, 2023 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlindquist/5ac8dab07509b6e0cb6ce4b50b75d0cb to your computer and use it in GitHub Desktop.
Save johnlindquist/5ac8dab07509b6e0cb6ce4b50b75d0cb to your computer and use it in GitHub Desktop.
// Name: Notify and Prompt
import "@johnlindquist/kit"
import { NotificationCenter } from "node-notifier"
// Hide when testing from the main menu
hide()
const notifier = new NotificationCenter()
notifier.notify(`Click Me`)
let clicked = new Promise(resolve => notifier.on("click", resolve)).then(() => true)
let timeout = new Promise(resolve => notifier.on("timeout", resolve)).then(() => false)
let clickedNotification = await Promise.race([clicked, timeout])
if (clickedNotification) {
let result = await arg("What's your name?")
inspect(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment