rgbcolor
The “rgbcolor” type handles RGB color values.
It supports hexadecimal colors:
#FF0000
FF0000
#F00
F00
RGB tuples or list (only from Python API for this one):
(255, 0, 0)
[255, 0, 0]
and named colors:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Device Profile
Example of a rgbcolor value type in a device profile:
profile = {
# ...
"settings": {
"color": {
"label": "LED color",
"description": "Set the mouse backlight color",
"cli": ["-c", "--color"],
"command": [0x05, 0x00],
"value_type": "rgbcolor",
"default": "#FF1800"
},
},
# ...
}
CLI
Example of CLI option generated with this handler:
-c COLOR, --color=COLOR
Set the mouse backlight color (e.g. red, #ff0000,
ff0000, #f00, f00, default: #FF1800)
Example of CLI usage:
rivalcfg --color=red
rivalcfg --color=ff0000
rivalcfg --color=f00
Functions
- class rivalcfg.handlers.rgbcolor.CheckColorAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)
Validate colors from CLI
- rivalcfg.handlers.rgbcolor.add_cli_option(cli_parser, setting_name, setting_info)
Add the given “rgbcolor” type setting to the given CLI arguments parser.
- Parameters:
cli_parser (ArgumentParser) – An
ArgumentParser
instance.setting_name (str) – The name of the setting.
setting_info (dict) – The information dict of the setting from the device profile.
- rivalcfg.handlers.rgbcolor.process_value(setting_info, color)
Called by the
rivalcfg.mouse.Mouse
class when processing a “rgbcolor” type setting.- Parameters:
setting_info (dict) – The information dict of the setting from the device profile.
color (str,tuple,list) – The color.
- Return type:
[int, int, int]