Generating a Stream Deck Plugin
· 494 words · 3 minutes read
Introduction
Creating a custom plugin for an Elgato Stream Deck is relatively straight forward when following their directions, however there is one part that I am not a fan of:
During the development of your plugin, you worked with a
.sdPlugin
folder. However when your plugin is finalized, you shouldn’t share this folder directly. Instead you should create a.streamDeckPlugin
file using theDistributionTool
.
Quote from documentation as of the publication date of this article. The problem is this tool only runs on Windows and Mac, however my build jobs run in linux which means I can’t use this tool, so I investigated mimicking this functionality in linux.
Packaging
Packaging was the easier part of DistributionTool
to copy. If you look at a the .streamDeckPlugin file that DistributionTool
creates in a hex editor you’ll see the first few bytes are 0x504B0304
, looking up the file signature you’ll see this is a zip file. You can confirm this by changing the file format of to .zip and see that you can explore the archive; neat! This means you can simply create a zip file in your CI pipeline which will be installable via the Stream Deck if you are create it in the right directory format. So based on this information I ended up with a GitLab CI stage that creates the plugin file like this:
generate-bundle:
stage: dist
image: ubuntu:20.04
before_script:
- apt update && apt install -y zip
script:
- mkdir dev.sean.lifx.sdPlugin
- cp lifx-streamdeck.exe dev.sean.lifx.sdPlugin # windows output from a previous step
- cp lifx-streamdeck dev.sean.lifx.sdPlugin # mac output from a previous step
- cp manifest.json dev.sean.lifx.sdPlugin
- cp property-inspector/* dev.sean.lifx.sdPlugin
- cp images/* dev.sean.lifx.sdPlugin
- zip -r dev.sean.lifx.streamDeckPlugin dev.sean.lifx.sdPlugin
artifacts:
paths:
- dev.sean.lifx.streamDeckPlugin
This could easily be ported into your CI provider of choice whether it’s GitHub Actions, CircleCI, TeamCity, etc. simply by taking all your dependent files and zipping them up.
Validation
Validation is a bit more difficult as DistributionTool
is a compiled binary which makes it difficult to determine what they are validating. I don’t have a good solution to solve this yet other than checking for required keys per their manifest documentation here, and validating files referenced by the manifest exist, but I haven’t gone down that route as it seems like more effort than it’s worth. My current strategy is to run the validation using DistributionTool
by hand to validate and then leverage the CI output for “released” versions of my plugin.
Conclusion
Creating an archive that can be distributed to Stream Deck users in a CI pipeline in linux is relatively simple, validating the plugin is not so straight forward, but with more effort could be done. Ideally Elgato will release a version of DistributionTool
for Linux, but given that the Stream Deck doesn’t have a Linux companion app I don’t see it happening soon.
If you are planning on purchasing a Stream Deck, please consider using my affiliate link as it would help me out.