npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@meetfranz/electron-notification-state

v1.0.0

Published

Should you send a notification?

Downloads

19

Readme

electron-notification-state

Should you display a notification to your user? This module allows you to check.

Usage

Do Not Disturb / Quiet Hours

const { getDoNotDisturb } from 'electron-notification-state'
// On Windows, logs `true` if "quiet hours" are enabled
// On macOS, logs `true` if "do not disturb" is enabled
console.log(getDoNotDisturb());

Session State

On Windows, you likely want to check SHQueryUserNotificationState, checking whether or not a screensaver is running, if the screen is locked, or if a presentation is running. On macOS, you likely want to check if the screen is locked and if the if the user has an active screen session.

The call below logs a different string, depending on the platform:

macOS

  • SESSION_SCREEN_IS_LOCKED The screen is locked.
  • SESSION_ON_CONSOLE_KEY The user currently has console/graphical control.

Windows

  • QUNS_NOT_PRESENT A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress.
  • QUNS_BUSY A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click.
  • QUNS_RUNNING_D3D_FULL_SCREEN A full-screen (exclusive mode) Direct3D application is running.
  • QUNS_PRESENTATION_MODE The user has activated Windows presentation settings to block notifications and pop-up messages.
  • QUNS_ACCEPTS_NOTIFICATIONS None of the other states are found, notifications can be freely sent.
  • QUNS_QUIET_TIME Introduced in Windows 7. The current user is in "quiet time", which is the first hour after a new user logs into his or her account for the first time. During this time, most notifications should not be sent or shown. This lets a user become accustomed to a new computer system without those distractions. Quiet time also occurs for each user after an operating system upgrade or clean installation, according to Windows. This is not the same as "quiet hours". Note that during quiet time, if the user is in one of the other blocked modes (QUNS_NOT_PRESENT, QUNS_BUSY, QUNS_PRESENTATION_MODE, or QUNS_RUNNING_D3D_FULL_SCREEN) SHQueryUserNotificationState returns only that value, and does not report QUNS_QUIET_TIME.
  • QUNS_APP Introduced in Windows 8. A Windows Store app is running.
const { getSessionState } from 'electron-notification-state'

console.log(getSessionState());

License

MIT. Please see LICENSE for details.