settings: add ability to toggle boolean values in solaar config

#1325
This commit is contained in:
Łukasz Woźniak 2021-11-15 13:11:02 +01:00 committed by Peter F. Patel-Schneider
parent d33b407ba8
commit 27cda8bf08
1 changed files with 13 additions and 10 deletions

View File

@ -27,7 +27,7 @@ def _print_setting(s, verbose=True):
if s.description:
print('#', s.description.replace('\n', ' '))
if s.kind == _settings.KIND.toggle:
print('# possible values: on/true/t/yes/y/1 or off/false/f/no/n/0')
print('# possible values: on/true/t/yes/y/1 or off/false/f/no/n/0 or Toggle')
elif s.kind == _settings.KIND.choice:
print(
'# possible values: one of [', ', '.join(str(v) for v in s.choices),
@ -82,6 +82,9 @@ def select_choice(value, choices, setting, key):
def select_toggle(value, setting):
if value == 'Toggle':
value = not setting.read()
else:
try:
value = bool(int(value))
except Exception: