Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
elgato-stream-deck
Advanced tools
elgato-stream-deck
is a Node.js library for interfacing
with the various models of the Elgato Stream Deck.
❗ Please note that
node-elgato-stream-deck
is NOT a standalone application. It is not something you download and run on its own. It is not an alternative to the official Stream Deck program provided by Elgato. Instead,node-elgato-stream-deck
is a code library which provides an API to the Stream Deck. Developers can use this API to make their own applications which interface with the Stream Deck.To further clarify: this is not an installable program. There is no user interface, and you cannot do anything with this library on its own. Out of the box, this library does nothing. It's purpose is to provide tools for programmers to build programs from the ground up which interact with a Stream Deck.
This is a tool for developers to use. It is not a program for end users. It cannot and will not replace the official Stream Deck program. That is not its goal. However, it does enable someone to more easily write a program which does do that.
$ npm install --save elgato-stream-deck
$ npm install --save @julusian/jpeg-turbo@^0.5.3
(Optional)
It is recommended to install @julusian/jpeg-turbo@^0.5.3
to greatly improve performance for writing images to the StreamDeck XL or the Original-v2. Without doing so jpeg-js
will be used instead, but image transfers will be noticably more cpu intensive and slower. jpeg-turbo
has prebuilt binaries, but is not installed by default to ensure installation time is kept to a minimum for users who do not need the performance or the XL or the Original-v2.
On linux, the udev subsystem blocks access to the StreamDeck without some special configuration.
Save the following to /etc/udev/rules.d/50-elgato.rules
and reload the rules with sudo udevadm control --reload-rules
SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006d", MODE:="666", GROUP="plugdev"
Unplug and replug the device and it should be usable
All of this library's native dependencies ship with prebuilt binaries, so having a full compiler toolchain should not be necessary to install node-elgato-stream-deck
.
However, in the event that installation does fail (or if you are on a platform that our dependencies don't provide prebuilt binaries for, such as a Raspberry Pi), you will need to install a compiler toolchain to enable npm to build some of node-elgato-stream-deck
's dependencies from source. Expand the details block below for full instructions on how to do so.
windows-build-tools
:npm install --global windows-build-tools
xcode-select --install
node-hid
:
sudo apt-get install build-essential git
sudo apt-get install gcc-4.8 g++-4.8 && export CXX=g++-4.8
sudo apt-get install sudo apt install libusb-1.0-0 libusb-1.0-0-dev
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
node-elgato-stream-deck
sudo apt-get update && sudo apt-get upgrade
down
and key up
eventsconst path = require('path')
const { openStreamDeck } = require('elgato-stream-deck')
// Automatically discovers connected Stream Decks, and attaches to the first one.
// Throws if there are no connected stream decks.
// You also have the option of providing the devicePath yourself as the first argument to the constructor.
// For example: const myStreamDeck = new StreamDeck('\\\\?\\hid#vid_05f3&pid_0405&mi_00#7&56cf813&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}')
// On linux the equivalent would be: const myStreamDeck = new StreamDeck('0001:0021:00')
// Available devices can be found with listStreamDecks()
const myStreamDeck = openStreamDeck()
myStreamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex)
})
myStreamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex)
})
// Fired whenever an error is detected by the `node-hid` library.
// Always add a listener for this event! If you don't, errors will be silently dropped.
myStreamDeck.on('error', error => {
console.error(error)
})
// Fill the first button form the left in the first row with a solid red color. This is synchronous.
myStreamDeck.fillColor(4, 255, 0, 0)
console.log('Successfully wrote a red square to key 4.')
import { openStreamDeck } = require('elgato-stream-deck')
const myStreamDeck = openStreamDeck() // Will throw an error if no Stream Decks are connected.
myStreamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex)
})
myStreamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex)
})
// Fired whenever an error is detected by the `node-hid` library.
// Always add a listener for this event! If you don't, errors will be silently dropped.
myStreamDeck.on('error', error => {
console.error(error)
})
> openStreamDeck(path?: string, options?: OpenStreamDeckOptions) -> StreamDeckDeviceInfo | undefined
Opens a StreamDeck.
If a path is provided, then a specific device will be opened, otherwise the first found device will be used. See listDevices for info on how to discover devices.
Some device types have additional options, as part of the options object. This is not required to be provided.
Options:
const streamDeck = openStreamDeck()
// Or
const streamDeck = openStreamDeck('0001:0021:00')
// Or
const streamDeck = openStreamDeck('0001:0021:00', {
useOriginalKeyOrder: true
})
> listStreamDecks() -> Array<StreamDeckDeviceInfo>
This will scan for and list all detected StreamDeck devices on the system along with their model. The path property can be passed into the constructor to open a specific device.
console.log('Devices: ', listStreamDecks())
/**
* Devices: [
* {
* model: 'original',
* path: '0001:0023:00',
* serialNumber: 'AL37G1A02840'
* },
* {
* model: 'xl',
* path: '0001:0021:00',
* serialNumber: 'CL18I1A00913'
* }
* ]
*/
> getStreamDeckInfo(path: string) -> StreamDeckDeviceInfo | undefined
Get the info for a given device. Returns undefined
if the path is not a valid StreamDeck
console.log('Info: ', getStreamDeckInfo('0001:0021:00'))
/**
* Info: {
* model: 'xl',
* path: '0001:0021:00',
* serialNumber: 'CL18I1A00913'
* }
*/
> streamDeck.fillColor(keyIndex, r, g, b) -> undefined
Synchronously sets the given keyIndex
's screen to a solid RGB color.
An error will be thrown if the keyIndex is not valid, of a colour component is outside of the range 0-255
// Turn key 4 (the top left key) solid red.
streamDeck.fillColor(4, 255, 0, 0)
> streamDeck.fillImage(keyIndex, buffer) -> undefined
Synchronously writes a buffer of RGB image data to the given keyIndex
's screen.
The required size of the buffer varies by device, and must be the exact length. Any other length will result in an error being thrown.
The expected sizes are:
// Fill the third button from the left in the first row with an image of the GitHub logo.
const sharp = require('sharp') // See http://sharp.dimens.io/en/stable/ for full docs on this great library!
sharp(path.resolve(__dirname, 'github_logo.png'))
.flatten() // Eliminate alpha channel, if any.
.resize(streamDeck.ICON_SIZE, streamDeck.ICON_SIZE) // Scale up/down to the right size, cropping if necessary.
.raw() // Give us uncompressed RGB.
.toBuffer()
.then(buffer => {
streamDeck.fillImage(2, buffer)
})
.catch(err => {
console.error(err)
})
> streamDeck.fillPanel(buffer) -> undefined
Applies an image to the entire panel, spreading it over all keys. The image must be exactly the correct resolution for your device. Any other size will result in an error being thrown.
// Fill the entire panel with a photo of a sunny field.
const sharp = require('sharp') // See http://sharp.dimens.io/en/stable/ for full docs on this great library!
sharp(path.resolve(__dirname, 'github_logo.png'))
.flatten() // Eliminate alpha channel, if any.
.resize(streamDeck.ICON_SIZE * streamDeck.KEY_COLUMNS, streamDeck.ICON_SIZE * streamDeck.KEY_ROWS) // Scale up/down to the right size, cropping if necessary.
.raw() // Give us uncompressed RGB.
.toBuffer()
.then(buffer => {
streamDeck.fillPanel(buffer)
})
.catch(err => {
console.error(err)
})
> streamDeck.clearKey(keyIndex) -> undefined
Synchronously clears the given keyIndex
's screen.
An error will be thrown if the keyIndex is not valid
// Clear the third button from the left in the first row.
streamDeck.clearKey(2)
> streamDeck.clearAllKeys() -> undefined
Synchronously clears all keys on the device.
// Clear all keys.
streamDeck.clearAllKeys()
> streamDeck.setBrightness(percentage) -> undefined
Synchronously set the brightness of the Stream Deck. This affects all keys at once. The brightness of individual keys cannot be controlled. An error will be thrown if the brightness is not in the range 0-100
// Set the Stream Deck to maximum brightness
streamDeck.setBrightness(100)
> streamDeck.resetToLogo() -> undefined
Resets the device back to the startup Elgato logo.
// Set the Stream Deck back to the Elgato logo
streamDeck.resetToLogo()
> streamDeck.getFirmwareVersion() -> string
Gets the firmware version number.
console.log(streamDeck.getFirmwareVersion())
> streamDeck.getSerialNumber() -> string
Gets the serial number of the device.
console.log(streamDeck.getSerialNumber())
> down
Fired whenever a key is pressed. keyIndex
is the index of that key.
streamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex)
})
> up
Fired whenever a key is released. keyIndex
is the index of that key.
streamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex)
})
> error
Fired whenever an error is detected by the node-hid
library.
Always add a listener for this event! If you don't, errors will be silently dropped.
streamDeck.on('error', error => {
console.error(error)
})
The elgato-stream-deck team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be kind to each other.
Please refer to the Changelog for project history details, too.
Raw protocol notes can be found in NOTES.md. These detail the protocol and method for interacting with the Stream Deck which this module implements.
FAQs
An npm module for interfacing with the Elgato Stream Deck
The npm package elgato-stream-deck receives a total of 23 weekly downloads. As such, elgato-stream-deck popularity was classified as not popular.
We found that elgato-stream-deck demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.