├── .appcast.xml
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .npmrc
├── assets
└── icon.png
├── license
├── package-lock.json
├── package.json
├── readme.md
└── src
├── index.js
└── manifest.json
/.appcast.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 | -
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = tab
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [*.yml]
11 | indent_style = space
12 | indent_size = 2
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | icon-preview.sketchplugin
2 | node_modules
3 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sindresorhus/sketch-icon-preview/09746e5f0280a5a15d1de433c46b30ddfd91ad11/assets/icon.png
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "version": "1.1.1",
4 | "type": "module",
5 | "repository": "sindresorhus/sketch-icon-preview",
6 | "skpm": {
7 | "name": "icon-preview",
8 | "manifest": "src/manifest.json",
9 | "main": "icon-preview.sketchplugin",
10 | "assets": [
11 | "assets/**/*"
12 | ]
13 | },
14 | "scripts": {
15 | "build": "skpm-build",
16 | "watch": "skpm-build --watch",
17 | "start": "skpm-build --watch --run",
18 | "postinstall": "npm run build && skpm-link"
19 | },
20 | "devDependencies": {
21 | "@skpm/builder": "^0.9.5"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # sketch-icon-preview
2 |
3 | > Sketch plugin to preview macOS app icons in the Dock using the [Icon Preview](https://sindresorhus.com/icon-preview) app
4 |
5 | The artboard of your macOS app icon must have a name that contains the text “AppIcon”.
6 |
7 | The icon is updated in the Dock automatically when the document is saved.
8 |
9 | ## Install
10 |
11 | - Get the [Icon Preview](https://sindresorhus.com/icon-preview) app
12 | - [Download](../../releases/latest/download/icon-preview.sketchplugin.zip) the plugin, unzip, and double-click
13 |
14 | ## Preview
15 |
16 | 
17 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | /* globals NSWorkspace, NSURL, NSWorkspaceLaunchWithoutActivation, NSTemporaryDirectory */
2 | import sketch from 'sketch';
3 |
4 | const iconPreviewBundleId = 'com.sindresorhus.Icon-Preview';
5 |
6 | function openInIconPreview(artboard, directoryPath) {
7 | const workspace = NSWorkspace.sharedWorkspace();
8 | const filePath = `${directoryPath}${artboard.id}.png`;
9 |
10 | workspace.openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers(
11 | [
12 | NSURL.fileURLWithPath(filePath),
13 | ],
14 | iconPreviewBundleId,
15 | NSWorkspaceLaunchWithoutActivation,
16 | null,
17 | null,
18 | );
19 | }
20 |
21 | export function onDocumentSaved(context) {
22 | const document = sketch.fromNative(context.actionContext.document);
23 |
24 | const selectedArtboard = document.selectedPage.layers.find(layer => layer.type === 'Artboard' && layer.name.includes('AppIcon'));
25 | if (!selectedArtboard) {
26 | return;
27 | }
28 |
29 | const directoryPath = `${NSTemporaryDirectory()}icon-preview/`;
30 |
31 | sketch.export(selectedArtboard, {
32 | output: directoryPath,
33 | formats: 'png',
34 | overwriting: true,
35 | 'use-id-for-name': true,
36 | });
37 |
38 | openInIconPreview(selectedArtboard, directoryPath);
39 | }
40 |
--------------------------------------------------------------------------------
/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/sketch-hq/SketchAPI/develop/docs/sketch-plugin-manifest-schema.json",
3 | "identifier": "com.sindresorhus.sketch.plugin.icon-preview",
4 | "name": "Icon Preview",
5 | "version": "1.1.1",
6 | "description": "Preview macOS app icons using the Icon Preview app",
7 | "homepage": "https://github.com/sindresorhus/sketch-icon-preview",
8 | "appcast": "https://github.com/sindresorhus/sketch-icon-preview/raw/main/.appcast.xml",
9 | "author": "Sindre Sorhus",
10 | "authorEmail": "sindresorhus@gmail.com",
11 | "compatibleVersion": "60",
12 | "icon": "icon.png",
13 | "commands": [
14 | {
15 | "name": "Preview",
16 | "identifier": "preview",
17 | "script": "./index.js",
18 | "handlers": {
19 | "actions": {
20 | "DocumentSaved": "onDocumentSaved"
21 | }
22 | }
23 | }
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------