An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# node-mac-app-icon

[![Build Status](https://travis-ci.org/sallar/node-mac-app-icon.svg?branch=master)](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)