diff options
Diffstat (limited to 'kvmd/validators')
-rw-r--r-- | kvmd/validators/kvm.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py index cf63b97e..b32a785e 100644 --- a/kvmd/validators/kvm.py +++ b/kvmd/validators/kvm.py @@ -24,8 +24,10 @@ from typing import Any from ..keyboard.mappings import KEYMAP +from . import raise_error from . import check_string_in_list +from .basic import valid_stripped_string_not_empty from .basic import valid_number from .os import valid_printable_filename @@ -56,6 +58,17 @@ def valid_stream_fps(arg: Any) -> int: return int(valid_number(arg, min=0, max=120, name="stream FPS")) +def valid_stream_resolution(arg: Any) -> str: + name = "stream resolution" + arg = valid_stripped_string_not_empty(arg, name) + parts = arg.split("x") + if len(parts) != 2: + raise_error(arg, name) + width = int(valid_number(parts[0], min=1, name=f"{name} (width)")) + height = int(valid_number(parts[1], min=1, name=f"{name} (height)")) + return f"{width}x{height}" + + # ===== def valid_hid_key(arg: Any) -> str: return check_string_in_list(arg, "HID key", KEYMAP, lower=False) |