Add "Show On Same Device" to SF Deck methods
I think it'd be great if the "Show Deck on Stream Deck" and "Open Deck (Show on Device)" commands got support for one more option: "Open on Same Device", like we're allowed to do when we have a Deck assigned to another Deck's button.
Something like this would be fabulous:
sf.decks.get('foo:bar').showOnStreamDeck({
device: "openOnSameDevice",
});
// or //
sf.decks.get('foo:bar').showOnStreamDeck({
device: "",
openOnSameDevice: true
});
For me this would help a lot. I created my first package, and it's really about StreamDeck layouts I made. But sometimes I want to load specific decks at the same time as running a command. But I can't really script this for other users who have unknown devices to me. I'd love to be able to run a script action that does whatever, but also loads one of my pre-made Decks onto the current device. Having this extra argument as an option would make this possible, particularly when making packages for other users in the community to utilize.
Linked from:
- Christian Scheuer @chrscheuer2024-04-08 22:52:34.496Z
If the script in question is being run from a deck, you could do:
sf.decks.get('foo:bar').showOnStreamDeck({ device: event.deck.device, });
- MMatt Friedman @Matt_Friedman
That helps a lot! So I can ignore the inspection error that the SF editor highlights on "device" not being the expected property type?
Christian Scheuer @chrscheuer2024-04-09 01:03:25.017Z
The correct action to use is actually the
open
action instead, which has proper highlighting:sf.decks.get('blabla').open({ device: event.deck.device, });
- In reply tochrscheuer⬆:MMatt Friedman @Matt_Friedman
Sort of a related follow up.
If I set up a template script, and one of the properties is AxDeck or AxDeckOrPreset, in the event.props for that one, is it possible to get the local command id of whatever Deck is selected from the AxDeck/AxDeckOrPreset property?
Christian Scheuer @chrscheuer2024-04-09 01:04:09.381Z
Yes it probably would be, but it's easier to help if you tell us why you think you need that id (as I think you won't need the id).
- MMatt Friedman @Matt_Friedman
Well I have a simple script that does the following:
- Run an action (in this case just a simple press keys action)
- Load a specific Deck from my package onto the current device
Since I have about a half dozen of these Scripts, all with identical code, the only differences being the keys being pressed and the decks being loaded, I figured I'd turn one script into a template, so I could use presets to define the 2 variables needed - the keys to press and the Deck to load. I thought it'd be super cool to use the AxDeck property in that case so I can select from the decks themselves, assuming it was simple to extract a deck's command ID from the AxDeck property.
If not though, I can just as easily have normal individual scripts... I was just looking into a way to condense them into one as a template, just for the sake of code tidiness.
Christian Scheuer @chrscheuer2024-04-09 03:38:16.542Z
If the property is called
myDeck
for example, then it would be of typeAxDeck
.As such, you don't need its ID.
sf.decks.get('...')
also gives you aAxDeck
.So, if your property is a
AxDeck
, you could just do:/**@type {AxDeck} */ const myDeck = event.props.myDeck; myDeck.open({ device: event.deck.device, });
- MMatt Friedman @Matt_Friedman
That seems to work perfect for me. Thanks!!