stream-deck-linux
Custom Linux control software for the Elgato Stream Deck, written in Rust.
Assign every key a picture and a function from a simple TOML file.
It talks to the device directly over /dev/hidraw* - no libhidapi, no
libusb, no system services. The wire protocol is grounded in the device's own
HID report descriptor, not guessed.
Verified end-to-end on a Stream Deck MK.2 (0fd9:0080): device identity,
brightness, key images (colour, pictures, text), button events and built-in
actions all confirmed against real hardware.
Features
- Per-key pictures (PNG/JPEG, auto-resized), solid colours, and
centred text labels (with a bundled font), or any combination.
- Per-key icons by name from the Lucide set (embedded
in the binary), tinted in the label colour and searchable by word.
- A written design language (
docs/style.md): a palette
for what keys do, with label, icon and layout rules programs can read.
- Per-key functions: run a shell command, a macro (command sequence),
or a device built-in (brightness, media, volume, open, page switch).
- Multi-page layouts, toggle / multi-state keys, and live keys
whose label is refreshed from a command (clock, stats, ...).
- Hold-a-key latch: press to hold a keyboard key/combo down, press again to
release, via a virtual uinput keyboard (X11 + Wayland).
- Press feedback: keys highlight while held.
- A single TOML config describes the whole layout.
- A system tray (StatusNotifierItem) with quick actions and a daemon.
- A web-based editor: page tabs, fuzzy application search, toggle
states, live + macro keys; changes apply to the device live.
- Autostart on login via a freedesktop
.desktop entry.
- A handful of one-shot CLI commands for quick tweaks and scripting.
Hardware support
| Model |
USB id |
Status |
| Stream Deck MK.2 |
0fd9:0080 |
Verified on hardware |
The model registry (src/model.rs) is structured so other Stream Decks slot in
by adding their key grid and image spec.
Install
cargo build --release
# binary at target/release/streamdeck
Permissions
The device node (/dev/hidraw*) must be accessible to your user. The common
approach is a udev rule that grants the logged-in user access via uaccess:
# /etc/udev/rules.d/70-streamdeck.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", TAG+="uaccess"
Then reload rules and replug the device:
sudo udevadm control --reload-rules && sudo udevadm trigger
Verify with streamdeck list.
Quick start
streamdeck list # find connected decks
streamdeck info # model, firmware, serial
streamdeck brightness 70 # 0-100
streamdeck color 0 1E1E2E # fill key 0 with a colour
streamdeck image 2 ~/pics/icon.png # render a picture onto key 2
streamdeck clear # blank all keys
streamdeck reset # back to the standby logo
streamdeck watch # print button press/release events
streamdeck run examples/demo-config.toml # render layout + dispatch actions
run with no path looks at $XDG_CONFIG_HOME/streamdeck/config.toml
(usually ~/.config/streamdeck/config.toml).
Desktop app: tray, editor and autostart
streamdeck tray # run the daemon with a system-tray icon + web editor
streamdeck ui # open the web editor (and run the daemon)
streamdeck autostart enable # start `streamdeck tray` on login
streamdeck autostart status
streamdeck autostart disable
- Tray menu: open editor, reload config, brightness +/-, reset device, quit.
The tray uses a pure-Rust StatusNotifierItem implementation (no GTK) and the
embedded app icon, so it works on KDE, GNOME (with an SNI extension),
Cinnamon/XApp and other SNI hosts.
- Web editor: served locally (e.g.
http://127.0.0.1:NNNNN). Pick a key to
set its label, icon (searched as you type, with a preview), text colour,
background colour (the style's palette is offered as named swatches), image
path and action. Edits
apply live - there is no Save button; every change renders on the device
and is written to the config immediately. Each tile previews exactly what the
device shows.
- Editor guard: a key's action can run shell commands, so the editor's
server refuses any request not addressed to it as
127.0.0.1:<port> or
localhost:<port> (foreign-host, against DNS rebinding), any request from
another web origin (foreign-origin), and any write not sent as
application/json (not-json, so a page cannot send one without a CORS
preflight the server never grants). Each refusal is logged.
- Open application: the editor lists installed desktop apps; choose one and
the key launches it (via
gtk-launch), auto-filling the label and, when a
raster icon is found, the key image.
- Autostart: writes
~/.config/autostart/streamdeck.desktop pointing at the
current binary's tray mode. A first run creates a starter config if none
exists.
The generated icons live in assets/icons/
(cargo run --example gen-icon regenerates them).
Control API and CLI client
Programs (scripts, assistants) read what the deck shows and change the layout through the running
daemon, never by writing the file: each change is validated, written atomically and shown on the
device at once. Every caller holds its own token.
streamdeck token issue cli # once: a token for your own CLI
streamdeck layout # the layout, as JSON, with its revision
streamdeck schema # every key field, built-in and hold key this build knows
streamdeck view # what the deck shows now: page, brightness, each key as a PNG
streamdeck icons play # icons a key may show, best matches first (no token needed)
streamdeck style # the palette and the label, icon and layout rules (no token needed)
streamdeck key set 0 4 '{"icon":"mail","label":"Mail","color":"#2E5A88","run":"thunderbird"}'
streamdeck key clear 0 4
streamdeck page add Media
streamdeck layout brightness 60
The routes, the live view, icons, the style, tokens, revisions and named refusals are in
docs/control-api.md.
Icons and style
A key's icon is a Lucide icon by name. It is drawn centred in the key's
text_color (white by default) over its color; with a label the icon sits above a smaller label,
without one it fills more of the key. Toggle states take an icon each too.
[[buttons]]
key = 0
icon = "mail"
label = "Mail"
color = "#2E5A88"
run = "thunderbird"
- Find names with
streamdeck icons <words> (Lucide's names and tags, best first) or the editor's
icon search.
- An unknown name is refused with close ones:
unknown icon 'mial'; did you mean mail?. A key shows
an image or an icon, never both.
- The icons are embedded in the binary at build time; the daemon reads no icon files.
- How keys should look (the palette, and how to word labels, choose icons and place keys) is in
docs/style.md, and as data from streamdeck style.
Config reference
A config is TOML with an optional brightness and a list of [[buttons]].
brightness = 70 # 0-100, applied on load
[[buttons]]
key = 0 # hardware key index (0..N-1)
image = "icons/app.png" # relative to this file; ~ expands to $HOME
label = "App" # optional centred text, drawn over the background
text_color = "#FFFFFF" # optional, defaults to white
run = "alacritty" # shell command on press (via sh -c)
[[buttons]]
key = 5
color = "#444466" # solid colour background (#RRGGBB or RRGGBB)
label = "Bright+"
builtin = "brightness_up" # device-native action instead of `run`
Button fields
| Field |
Meaning |
key |
Hardware key index (required). |
image |
Picture file; relative paths resolve next to the config file. |
icon |
A Lucide icon by name, tinted in text_color; not with image. |
color |
Solid background #RRGGBB (used if no image, or as text bg). |
label |
Centred text, auto-shrunk to fit; drawn over the background. |
text_color |
Label colour #RRGGBB (default white). |
run |
Shell command executed on press. |
builtin |
Device-native action on press. |
macro |
Array of shell commands run in order on press. |
watch |
Command whose stdout becomes the key label (a live key). |
interval |
Refresh seconds for watch (default 5). |
states |
Toggle key: states cycled on press (each w/ visual + action). |
hold |
Hold a keyboard key/combo down; next press releases (a latch). |
Exactly one action per key (run / builtin / macro / hold / states); a
key needs at least one of image, icon, color, label or watch. Top-level options:
brightness (0-100) and press_feedback (highlight a key while pressed,
default true).
Built-in actions
builtin value |
Effect |
brightness_up/down |
Adjust brightness by 10%. |
brightness_max/min |
Brightness to 100% / 0%. |
brightness_set:N |
Set brightness to N% (0-100). |
media_play_pause |
Play / pause (via playerctl). |
media_next/prev |
Next / previous track. |
volume_up/down |
Volume +/- (wpctl / pactl / amixer). |
volume_mute |
Toggle mute. |
open:<url|file> |
Open with the desktop default handler. |
page_next/prev |
Switch pages (wraps). |
page:<name|index> |
Switch to a specific page. |
reset |
Reset device to its standby logo. |
Hold a key (latch)
A hold key presses a keyboard key (or combo) down and keeps it held on the
first press, and releases it on the next press of the same deck key. Useful
for push-to-talk, sprint-toggles in games, or holding a modifier.
[[buttons]]
key = 0
label = "Sprint"
color = "#444466"
hold = "shift" # latch: press to hold Shift, press again to release
[[buttons]]
key = 1
label = "C+S+F"
color = "#334455"
hold = "ctrl+shift+f" # combos with `+`; modifiers press first, release last
While latched on, the key shows a persistent highlight. Key names are
case-insensitive: letters a-z, digits 0-9, f1-f12, ctrl/control,
shift, alt, super/meta/win, altgr, space, enter/return, tab,
esc/escape, backspace, delete, insert, home, end, pageup,
pagedown, arrows, minus, equal, comma, dot/period, slash,
semicolon.
Holds are emitted through a pure-Rust virtual uinput keyboard, so they
deliver real key events on both X11 and Wayland (games and raw-input apps
see them too). If the daemon crashes or is stopped while a key is held, the
kernel auto-releases it when the device closes, so a key is never left stuck.
This needs write access to /dev/uinput. On many desktops your login session
already has it (check with getfacl /dev/uinput). If not, add a udev rule:
# /etc/udev/rules.d/71-uinput.rules
KERNEL=="uinput", GROUP="uinput", MODE="0660", OPTIONS+="static_node=uinput"
Then sudo groupadd -f uinput && sudo usermod -aG uinput "$USER", reload rules
(sudo udevadm control --reload-rules && sudo udevadm trigger) and re-log in.
Alternatively a TAG+="uaccess" rule grants the active session access.
Pages, macros, live keys and toggles
Use [[pages]] (each with a name + buttons) for multi-page layouts; switch
with the page_* built-ins. A macro runs a command sequence; a watch key
shows live command output; states makes a toggle. See
examples/showcase.toml and examples/multipage.toml. The web editor supports
all of this: page tabs, fuzzy app search, toggle states, live and macro keys.
How it works
protocol - pure builders/parsers for the HID reports (image packets,
brightness/reset feature reports, key-state input reports).
hid - a tiny pure-Rust hidraw backend (ioctl for feature reports and
device info, plain read