Show a variable value in a Stream Deck button

I can use the {VARIABLE} syntax to show the variable in HUDs but they don't seem to render in a Stream Deck button. Is there a way to do that? Or a possible workaround?

Currently you'd need to use a script widget for that. I'd recommend to use the "Real Java Script" source option:

async function loadTextWithVariables() {
    let yourVariable = await get_string_variable("BTTActiveWindowTitle")
    return `some text ${yourVariable}`
}

Thanks. This works. The only thing is if it's a script widget, then I might as well have the script setting the variable run here (which is what I ended up doing).

Would really be useful to have a regular Stream Deck button which does 2 things

  • Gets its text from a variable
  • Refreshes the current variable value on press of the button

This seems possible right now if I use a script widget with a very long time (say 24 hours) so it doesn't refresh as often. But for the click-to-refresh to work, there needs to be another script action (which would be the same script as the widget) which if can be avoided would make things simpler.

Yes, it is already on my todo list and will come at some point, however it's not super simple to add because it requires various state management additions that are currently not included - the current static widgets are very simple without much logic.

Thanks. I think even if it became possible to update the title of a static widget/button via scripts, that'd solve the click-to-refresh thing.

Appreciate your quick responses like always, and the amazing app!

that is already possible :wink:

JS:
https://docs.folivora.ai/docs/1106_java_script.html#updatestreamdeckwidget

Apple Script:
https://docs.folivora.ai/docs/1102_apple_script.html#updatestreamdeckwidget

Wait is that now supported?! (jumping with joy)

I recall the update_stream_deck_widget working only with script buttons on the Stream Deck.

That's true, however a script widget without script is basically the same as a static text widget - especially when checking this option:

1 Like