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 🙏

© 2026 – Pkg Stats / Ryan Hefner

desktop-detector

v1.4.0

Published

Detect when Windows desktop is in foreground

Readme

🖥️ desktop-detector

A small Windows utility and Node.js wrapper that detects when the desktop becomes the foreground window (i.e., when all applications are minimized).

This version improves detection by distinguishing between a true "Show Desktop" (triggered via Win+D or the taskbar button) and a simple click on the desktop:

  • Show Desktop is recognized when:
    • Any window minimize-start event occurs within a 500-millisecond window before desktop activation (meaning a "burst" of one or more minimization events).
    • It is triggered via the "Show Desktop" button or the Win+D hotkey.
  • A plain click on the desktop is ignored as a "Show Desktop" event and logs only a simple "shown" state.

⚙️ Features

  • Detects when the Windows desktop is shown or hidden (based on focus).
  • Distinguishes "Show Desktop" (via key/button) from ordinary clicks.
  • Exposes a clean JavaScript API for use in Node.js.
  • Optional --quiet and --log CLI flags for flexible output.

📦 Installation

npm install desktop-detector

Or clone it:

git clone https://github.com/nstechbytes/desktop-detector.git
cd desktop-detector
npm install

🚀 Usage

In Node.js:

const { startDesktopDetector } = require('desktop-detector');

// Start monitoring
const proc = startDesktopDetector({
  quiet: false, // show console output
  log: true     // also log to `detect-desktop.log`
});

// Optional: stop after 10 seconds
setTimeout(() => {
  proc.kill();
  console.log("Stopped detector.");
}, 10000);

🧰 CLI Options

You can also run the binary directly:

./bin/detect-desktop.exe [--quiet] [--log] [--help]

| Flag | Description | | --------- | ----------------------------------------- | | --quiet | Suppresses console output | | --log | Logs output to detect-desktop.log | | --help | Displays usage information |


🧪 Example Output

[2025-05-24 16:00:00] Initial state: Desktop is BACKGROUND
[2025-05-24 16:00:00] Listening for Show Desktop; press Ctrl+C to exit.
[2025-05-24 16:01:10] *** Desktop is now FOREGROUND (Show Desktop)
[2025-05-24 16:01:12] *** Desktop is now BACKGROUND (apps restored via desktopMode)
[2025-05-24 16:02:00] *** Desktop is now FOREGROUND (shown)

📜 License

MIT © nstechbytes