https://github.com/sallar/node-mac-app-icon
Get App icons by pid on macOS in NodeJS
https://github.com/sallar/node-mac-app-icon
icons macos pid swift
Last synced: about 1 year ago
JSON representation
Get App icons by pid on macOS in NodeJS
- Host: GitHub
- URL: https://github.com/sallar/node-mac-app-icon
- Owner: sallar
- License: mit
- Created: 2017-12-22T14:48:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-12T08:01:38.000Z (about 2 years ago)
- Last Synced: 2025-05-13T00:11:40.989Z (about 1 year ago)
- Topics: icons, macos, pid, swift
- Language: JavaScript
- Size: 66.4 KB
- Stars: 14
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-mac-app-icon
[](https://travis-ci.org/sallar/node-mac-app-icon)
Get App icons by pid on macOS in NodeJS. Returns a `Buffer` representation of the App's icon data.
The node source uses a [Swift](https://github.com/sallar/GetAppIcon) binary to fetch the icons so it's pretty fast.
Returning a `Buffer` is inspired by [sindresorhus/file-icon](https://github.com/sindresorhus/file-icon).
## Install
```sh
$ npm install node-mac-app-icon --save
```
## Functions
-
getAppIconByPid(pid, opts) ⇒Promise.<Buffer> -
Find an icon for a running application (by it's PID)
-
getAppIconListByPid(pidArray, opts) ⇒Promise.<Array.<ListResult>> -
Find icons for a list of running apps (by their PIDs)
## Typedefs
-
Options :Object -
ListOptions :Object -
ListResult :Object
## getAppIconByPid(pid, opts) ⇒ Promise.<Buffer>
Find an icon for a running application (by it's PID)
**Kind**: global function
**Returns**: Promise.<Buffer> - Buffer containing image data
| Param | Type | Description |
| --- | --- | --- |
| pid | number | App PID (Process ID) |
| opts | [ListOptions](#ListOptions) | |
**Example**
```js
const { getAppIconByPid } = require('node-mac-app-icon');
getAppIconByPid(814, { size: 32 }).then(res => {
console.log(res); // res is a Buffer
});
```
## getAppIconListByPid(pidArray, opts) ⇒ Promise.<Array.<ListResult>>
Find icons for a list of running apps (by their PIDs)
**Kind**: global function
**Returns**: Promise.<Array.<ListResult>> - Buffer containing image data
| Param | Type | Description |
| --- | --- | --- |
| pidArray | Array.<number> | App PID (Process ID) |
| opts | [Options](#Options) | |
**Example**
```js
const { getAppIconListByPid } = require('node-mac-app-icon');
getAppIconListByPid([814, 20134, 503], { size: 512 }).then(res => {
console.log(res); // array of { pid: ..., icon: ... }
});
```
## Options : Object
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| size | number | Size of output icon (in points) |
## ListOptions : Object
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| size | number | Size of output icon (in points) |
| failOnError | boolean | Fail hard if a pid in the list was not found |
## ListResult : Object
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| pid | number | PID of the application |
| icon | Buffer | Buffer containing image data |
## License
This software is licensed under the [MIT License](LICENSE)