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

customize power controls in config #185

Merged

Conversation

bits0rcerer
Copy link
Contributor

With this PR one can add, remove, customize an (virtual) infinite amount of power controls via the config file.


I don't really know if I got the toml macros 100% right but it works for me so it cannot be 100% wrong 😅

@coastalwhite
Copy link
Owner

Firstly, thank you very much for this PR.

I think this is a very nice feature to add.

The code looks good as well. There are two parts I would like to do a bit different.

  1. Could we replace the HashMap with a Vec? This way, we don't need the index anymore, which simplifies configuration and allows for less unfortunate errors to happen. It also makes the variable substitution possible again. This would lead to the configuration syntax shown below.
  2. I am also not really sure what the allow option does. Can you describe a use case where this would be used? Could the same be achieved by essentially setting cmd to true? If there is a use case that I am not thinking of, it might make more sense to make the key and command optional and use that instead.
# Shutdown option
[[power_controls.entries]]
# The text in the top-left to display how to shutdown. The text '%key%' will be
# replaced with the shutdown_key.
hint = "Shutdown %key%"

# The color and modifiers of the hint in the top-left corner
hint_color = "dark gray"
hint_modifiers = ""

# The key used to shutdown. Possibilities are F1 to F12.
key = "F1"
# The command that is executed when the key is pressed
cmd = "systemctl poweroff -l"

# Reboot option
[[power_controls.entries]]
# The text in the top-left to display how to reboot. The text '%key%' will be
# replaced with the shutdown_key.
hint = "Reboot %key%"

# The color and modifiers of the hint in the top-left corner
hint_color = "dark gray"
hint_modifiers = ""

# The key used to reboot. Possibilities are F1 to F12.
key = "F2"
# The command that is executed when the key is pressed
cmd = "systemctl reboot -l"

@bits0rcerer
Copy link
Contributor Author

  1. Could we replace the HashMap with a Vec? This way, we don't need the index anymore, which simplifies configuration and allows for less unfortunate errors to happen. It also makes the variable substitution possible again. This would lead to the configuration syntax shown below.

You are right, Vec is better.
Not so sure about the variable substitution (but probably skill issue on my end).

  1. I am also not really sure what the allow option does. Can you describe a use case where this would be used? Could the same be achieved by essentially setting cmd to true? If there is a use case that I am not thinking of, it might make more sense to make the key and command optional and use that instead.

True. allow is not necessary.

@bits0rcerer
Copy link
Contributor Author

feel free to revert 18b5799 if you dont like it

@coastalwhite
Copy link
Owner

I just did some small fixes to readd the possibility of partially specifying configuration. This also makes variable substitution possible on these entries. For convenience, I split the entries into two categories: base_entries and entries. You can clear either one by specifying them, so this allows you to specify additional entries using entries and keeps the base_entries in place.

Thank you very much for the PR. It is much appreciated.

@coastalwhite coastalwhite merged commit 09003a8 into coastalwhite:main Dec 1, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants