Documentation
¶
Overview ¶
Package streamdeck implements the Stream Deck SDK v2 WebSocket protocol.
Index ¶
- func ProviderIDFromAction(action string) string
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) GetGlobalSettings()
- func (c *Connection) Log(msg string)
- func (c *Connection) Logf(format string, args ...any)
- func (c *Connection) OpenURL(url string)
- func (c *Connection) ReadEvent() (Event, error)
- func (c *Connection) SendToPropertyInspector(context, action string, payload any)
- func (c *Connection) SetGlobalSettings(settings json.RawMessage)
- func (c *Connection) SetImage(context, svg string)
- func (c *Connection) SetSettings(context string, settings json.RawMessage)
- func (c *Connection) SetTitle(ctx, title string)
- type DidReceiveSettingsPayload
- type Event
- type GlobalSettingsEvent
- type GlobalSettingsPayload
- type LogMessageEvent
- type LogMessagePayload
- type OpenURLEvent
- type OpenURLPayload
- type RegistrationArgs
- type SendToPluginPayload
- type SendToPropertyInspectorEvent
- type SetImageEvent
- type SetImagePayload
- type SetSettingsEvent
- type SetTitleEvent
- type SetTitlePayload
- type SimpleEvent
- type TitleParameters
- type TitleParametersDidChangePayload
- type WillAppearPayload
- type WillAppearTitleParameters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProviderIDFromAction ¶
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) SendToPropertyInspector ¶ added in v0.3.3
func (c *Connection) SendToPropertyInspector(context, action string, payload any)
SendToPropertyInspector delivers a custom JSON payload to the PI for the given action + context. Used to reply to custom sendToPlugin requests (e.g., cookie-host status, registration results).
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) SetTitle ¶ added in v0.4.0
func (c *Connection) SetTitle(ctx, title string)
SetTitle sets the native Stream Deck title for a key.
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 SendToPropertyInspectorEvent ¶ added in v0.3.3
type SendToPropertyInspectorEvent struct {
Event string `json:"event"`
Action string `json:"action"`
Context string `json:"context"`
Payload json.RawMessage `json:"payload"`
}
SendToPropertyInspectorEvent delivers a custom payload from the plugin back to the Property Inspector. Action is the action UUID of the key whose PI is open (taken from the inbound sendToPlugin 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 ¶
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 ¶
SetTitlePayload carries the title text.
type SimpleEvent ¶
SimpleEvent is for events with just event + context (getSettings, getGlobalSettings, showAlert, showOk).
type TitleParameters ¶ added in v0.4.0
type TitleParameters struct {
ShowTitle bool `json:"showTitle"`
}
TitleParameters carries the native title display settings.
type TitleParametersDidChangePayload ¶ added in v0.4.0
type TitleParametersDidChangePayload struct {
Settings json.RawMessage `json:"settings"`
Title string `json:"title"`
TitleParameters TitleParameters `json:"titleParameters"`
}
TitleParametersDidChangePayload is sent when the user edits a key's title or title settings in the Stream Deck UI.
type WillAppearPayload ¶
type WillAppearPayload struct {
Settings json.RawMessage `json:"settings"`
Title string `json:"title"`
Row int `json:"row"`
Column int `json:"column"`
IsInMulti bool `json:"isInMultiAction"`
}
WillAppearPayload is the payload of a willAppear event.
type WillAppearTitleParameters ¶ added in v0.4.0
type WillAppearTitleParameters struct {
TitleParameters *TitleParameters `json:"titleParameters"`
}
WillAppearTitleParameters extends WillAppearPayload with title info. Parsed separately so existing code doesn't break.