Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change output / color depending on condition #49

Open
prankousky opened this issue Aug 24, 2021 · 3 comments
Open

change output / color depending on condition #49

prankousky opened this issue Aug 24, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@prankousky
Copy link

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 :)

@muesli
Copy link
Owner

muesli commented Aug 25, 2021

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.

@liljenstolpe
Copy link

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?

@vickyorlo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants