timothycrosley / streamdeck-ui

A Linux compatible UI for the Elgato Stream Deck.
https://timothycrosley.github.io/streamdeck-ui/
MIT License
1.16k stars 241 forks source link

Interacting with the streamdeck_ui from the called script #159

Open zanloy opened 3 years ago

zanloy commented 3 years ago

Basically I was wondering if there was a way for the called script in Command to return back data to update things on the deck like text or icon changes to the button that called the Command?

I assume since the code below seems to be calling the actual command and it's using Popen without defining any stdout or stderr pipes, there is no way currently for streamdeck_ui to handle any output or errors from the command. https://github.com/timothycrosley/streamdeck-ui/blob/f5a0dc260c1fd8377621a095a6baef7436c2939c/streamdeck_ui/gui.py#L229-L234

zanloy commented 3 years ago

For more context, I wrote a python script that toggles the pulse audio output between speakers and headphones and I'd like to update the button on the Stream Deck to either the headphone icon or a speaker icon.

gregfr commented 3 years ago

Very good idea!!! I've added a q&d patch (https://github.com/timothycrosley/streamdeck-ui/issues/135) to reload the config, but your idea is much cleaner.

NicolasGoeddel commented 2 years ago

That is a great idea. I was looking for this.

I could imagine that the command returns a JSON or YAML output which in turn can be parsed and then update the GUI.

Also some environment variables would be nice which contain the connected streamdeck ID, the page, the button.

For example: If you press button 2 on page 7 (0-based) then there could be this environment variables be available for the executed command:

Then the script could output something like the following which then can be merged into the current configuration.

{
    "streamdeck_ui_version": 1,
    "state": {
        "CL28K1A01234": {
            "buttons": {
                "7": {
                    "2": {
                        "icon": "/home/user/streamdeck/icons/mic-off.png"
                    }
                }
            }
        }
    }
}

Another idea would be to open a local socket and a small python module which can connect to the running streamdeck-ui instance using the socket given by an environment variable.

coolapso commented 1 year ago

hi, this project seems to be stale and a new fork as been made with the intention of replacing this one.

if this still an issue please reopen it at: https://github.com/streamdeck-linux-gui/streamdeck-linux-gui