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

electron-mac-dock-icon-switcher

v1.0.0

Published

> Change your app's Dock icon on macOS, so it persists after your app quits.

Downloads

3

Readme

electron-mac-dock-icon-switcher

Change your app's Dock icon on macOS, so it persists after your app quits.

You should install this in devDependencies because you'll configure your build process to copy the built .docktileplugin bundle into a folder inside your app bundle. Because of this, the switching icons can only work with your production app, not when running with the electron binary used in development.

Xcode Requirements

You must have xcodebuild installed and working properly. It comes with Xcode, but if there's an error, you may need to run sudo xcode-select --reset or use the -switch argument to set the location of your Xcode tools.

Install

npm install --save-dev electron-mac-dock-icon-switcher

Set Variable in .npmrc

You must add the three variables in your app's .npmrc file. Each string must be unique to your app.

  • dock_icon_notification_key is used as the system-wide macOS notification key for the "set" icon action. It is typically a reverse dns style string.
  • dock_icon_plugin_bundle_identifier is used as the unique identifier of the plugin bundle. It is typically a reverse dns style string. Note that this should be different from your app's bundle identifier.
  • dock_icon_class_name is used as the class name of the plugin that is loaded by the dock. It is typically a camel case first-letter-capitalized string, with a prefix unique to the developer or your project.

An example .npmrc file:

dock_icon_notification_key=com.demo.docktile.set
dock_icon_plugin_bundle_identifier=com.demo.docktile.plugin
dock_icon_class_name=MyDemoDockTilePlugin

If you change any of these values after running once, you'll need to clear the dock's cache between runs. Quit the app, remove it app from the dock, wait 5 seconds, then restart the Dock and SystemUIServer services:

sudo killall Dock
sudo killall SystemUIServer

Build Phase Requirements

  1. Set NSDockTilePlugIn in your app's Info.plist
  2. Copy DockTile.docktileplugin bundle to your app's bundle

forge.config.cjs example:

module.exports = {
	extendInfo: {
		NSDockTilePlugIn: "DockTile.docktileplugin",
	},
	packagerConfig: {
		afterComplete: [
			(buildPath, electronVersion, platform, arch, callback) => {
				if (platform == "darwin") {
					// Copy the plugin to the app bundle
					const fs = require("fs");
					const path = require("path");
					const pluginPath = path.join(
						__dirname,
						"node_modules",
						"electron-mac-dock-icon-switcher",
						"build",
						"Release",
						"DockTile.docktileplugin"
					);
					const pluginDest = path.join(
						buildPath,
						"MyApp.app", // TODO: replace with your bundle name
						"Contents",
						"PlugIns",
						"DockTile.docktileplugin"
					);
					fs.mkdirSync(pluginDest, { recursive: true });
					fs.cpSync(pluginPath, pluginDest, { recursive: true, overwrite: true });
				}
				callback();
			},
		],
	}
	...
}

Signing

You may need to sign the DockTile.docktileplugin bundle before distributing your app.

TODO: add instructions for signing with electron-forge

Not Allowed in Mac App Store

Last I heard, Apple does not allow apps with a docktileplugin in the Mac App Store.

Debugging

Build manually after checking out this repository:

./build.sh

Fixes some xcodebuild cli errors:

sudo xcode-select --reset

Check the plugin's binary to make sure your notification key is set correctly:

strings ./build/Release/DockTile.docktileplugin/Contents/MacOS/DockTile