streamdeck

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package streamdeck implements the Stream Deck SDK v2 WebSocket protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProviderIDFromAction

func ProviderIDFromAction(action string) string

ProviderIDFromAction extracts the provider ID from a Stream Deck action UUID. Returns "" if the UUID doesn't belong to this plugin.

e.g. "io.github.anthonybaldwin.usagebuttons.claude" → "claude"

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection wraps the WebSocket to the Stream Deck software.

func Connect

func Connect(args RegistrationArgs) (*Connection, error)

Connect establishes the WebSocket and sends the registration event.

func (*Connection) Close

func (c *Connection) Close() error

Close closes the underlying WebSocket.

func (*Connection) GetGlobalSettings

func (c *Connection) GetGlobalSettings()

GetGlobalSettings requests the plugin-wide settings.

func (*Connection) Log

func (c *Connection) Log(msg string)

Log writes a message to Stream Deck's per-plugin log file.

func (*Connection) Logf

func (c *Connection) Logf(format string, args ...any)

Logf is a formatted version of Log.

func (*Connection) OpenURL

func (c *Connection) OpenURL(url string)

OpenURL opens a URL in the user's default browser.

func (*Connection) ReadEvent

func (c *Connection) ReadEvent() (Event, error)

ReadEvent blocks until the next inbound event arrives.

func (*Connection) SetGlobalSettings

func (c *Connection) SetGlobalSettings(settings json.RawMessage)

SetGlobalSettings persists plugin-wide settings.

func (*Connection) SetImage

func (c *Connection) SetImage(context, svg string)

SetImage sends an SVG string as a base64 data URI to a key.

func (*Connection) SetSettings

func (c *Connection) SetSettings(context string, settings json.RawMessage)

SetSettings persists per-key settings.

func (*Connection) UUID

func (c *Connection) UUID() string

UUID returns the plugin UUID.

type DidReceiveSettingsPayload

type DidReceiveSettingsPayload struct {
	Settings json.RawMessage `json:"settings"`
}

DidReceiveSettingsPayload is the payload of didReceiveSettings.

type Event

type Event struct {
	Event   string          `json:"event"`
	Action  string          `json:"action,omitempty"`
	Context string          `json:"context,omitempty"`
	Device  string          `json:"device,omitempty"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

Event is the minimal envelope for every inbound message.

type GlobalSettingsEvent

type GlobalSettingsEvent struct {
	Event   string          `json:"event"`
	Context string          `json:"context"`
	Payload json.RawMessage `json:"payload"`
}

GlobalSettingsEvent sets plugin-wide global settings.

type GlobalSettingsPayload

type GlobalSettingsPayload struct {
	Settings json.RawMessage `json:"settings"`
}

GlobalSettingsPayload wraps didReceiveGlobalSettings.

type LogMessageEvent

type LogMessageEvent struct {
	Event   string            `json:"event"`
	Payload LogMessagePayload `json:"payload"`
}

LogMessageEvent writes to Stream Deck's plugin log.

type LogMessagePayload

type LogMessagePayload struct {
	Message string `json:"message"`
}

LogMessagePayload carries the log text.

type OpenURLEvent

type OpenURLEvent struct {
	Event   string         `json:"event"`
	Payload OpenURLPayload `json:"payload"`
}

OpenURLEvent opens a URL in the default browser.

type OpenURLPayload

type OpenURLPayload struct {
	URL string `json:"url"`
}

OpenURLPayload carries the URL to open.

type RegistrationArgs

type RegistrationArgs struct {
	Port          string
	PluginUUID    string
	RegisterEvent string
	Info          json.RawMessage
}

RegistrationArgs are parsed from the command-line flags that the Stream Deck software passes when launching a plugin binary.

func ParseArgs

func ParseArgs() RegistrationArgs

ParseArgs extracts the registration arguments from os.Args. Stream Deck passes: -port P -pluginUUID U -registerEvent E -info {...}

type SendToPluginPayload

type SendToPluginPayload struct {
	Action string `json:"action,omitempty"`
}

SendToPluginPayload is a custom PI → plugin event.

type SetImageEvent

type SetImageEvent struct {
	Event   string          `json:"event"`
	Context string          `json:"context"`
	Payload SetImagePayload `json:"payload"`
}

SetImageEvent sets the button image (SVG data URI).

type SetImagePayload

type SetImagePayload struct {
	Image  string `json:"image"`
	Target int    `json:"target"`
}

SetImagePayload carries the data URI.

type SetSettingsEvent

type SetSettingsEvent struct {
	Event   string          `json:"event"`
	Context string          `json:"context"`
	Payload json.RawMessage `json:"payload"`
}

SetSettingsEvent persists per-key settings.

type SetTitleEvent

type SetTitleEvent struct {
	Event   string          `json:"event"`
	Context string          `json:"context"`
	Payload SetTitlePayload `json:"payload"`
}

SetTitleEvent sets the button title.

type SetTitlePayload

type SetTitlePayload struct {
	Title  string `json:"title"`
	Target int    `json:"target"`
}

SetTitlePayload carries the title text.

type SimpleEvent

type SimpleEvent struct {
	Event   string `json:"event"`
	Context string `json:"context"`
}

SimpleEvent is for events with just event + context (getSettings, getGlobalSettings, showAlert, showOk).

type WillAppearPayload

type WillAppearPayload struct {
	Settings  json.RawMessage `json:"settings"`
	Row       int             `json:"row"`
	Column    int             `json:"column"`
	IsInMulti bool            `json:"isInMultiAction"`
}

WillAppearPayload is the payload of a willAppear event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL