deckmaster icon indicating copy to clipboard operation
deckmaster copied to clipboard

change output / color depending on condition

Open prankousky opened this issue 3 years ago • 3 comments

Hi,

I just recently discovered this project and really like it! I am mainly using it for controlling and monitoring, and it'd be great if the following was possible:

[[keys]]
  index = 15
[keys.widget]
  id = "command"
  [keys.widget.config]
    command = "cat /tmp/true_false'"
    font = "regular;bold;italic" # optional
    # if content of `cat /tmp/true_false` is true
    color = "#E06" # optional
    # else if content of `cat /tmp/true_false` is false
    color = "#fefefefe`
    # else
    color = #f0f0f0`
    # layout = "0x0+72x20;0x20+72x52" # optional

So basically, change a button depending on a state condition. One could even take this one step further with output... if it was true, don't display "true", but rather "switch: on" (in color x), and if it was false, display "switch: off" (in color y).

Can this be achieved with the current version of the program and/or will it be possible in later releases?

Thank you in advance for your help :)

prankousky avatar Aug 24 '21 07:08 prankousky

It's not currently possible, but we could use Go's template engine to achieve something like this in a future release. I'll think about how we can integrate this without the config becoming too convoluted.

muesli avatar Aug 25 '21 00:08 muesli

Let me expand this a bit. Here is what I am trying to do.

  1. Toggle the mute for a pulse audio default mic
  2. Toggle the mute for a pusle audio default sink
  3. Park or unpark a web cam
  4. Turn on (and possibly select temp and brightness) for a set of key lights.

All of this can be done with one-line commands. I would like to show current state (as there are other ways to toggle them as well), and that state is also a one-line command.

Creating widgets may be a bit overkill for this, but right now it is the only way I can accomplish this. What I would really like is:

  1. change the state of the button based on the output of a command (so case or if/then/else) - much as discussed here. Use the refresh timer to trigger that command

  2. Allow a button press (or press and hold) to do multiple actions, including setting a variable.

  3. Allow that variable to be uses in the state update function in (1).

So, this is somewhat of an expansion of this issue (mainly the state variable and the ability to reference it).

Thoughts?

liljenstolpe avatar Feb 25 '22 18:02 liljenstolpe

I want to add that the official Elgato software has the concept of a 'toggle switch' action (at least I think that's what they call it?), and I think something very similar could be implemented as a widget. The switch has two states, and each state has an icon, label and action assigned to it. Pressing the switch toggles between the states. A great extension for this concept would be a toggle switch with a higher number of states, where the state is controlled by the output of some user-provided command. Everything else could be implemented with a bunch of very short user-provided bash scripts, I think.

vickyorlo avatar Nov 07 '22 20:11 vickyorlo