2022-02-14 09:14:46 -08:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
|
|
|
<a id="jc.parsers.xrandr"></a>
|
|
|
|
|
|
|
|
# jc.parsers.xrandr
|
|
|
|
|
2022-03-04 13:27:39 -08:00
|
|
|
jc - JSON Convert `xrandr` command output parser
|
2022-02-14 09:14:46 -08:00
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
|
|
|
$ xrandr | jc --xrandr
|
2023-02-21 17:19:17 -08:00
|
|
|
$ xrandr --properties | jc --xrandr
|
2022-02-14 09:14:46 -08:00
|
|
|
|
2022-08-15 13:51:48 -07:00
|
|
|
or
|
2022-02-14 09:14:46 -08:00
|
|
|
|
|
|
|
$ jc xrandr
|
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
|
|
|
import jc
|
|
|
|
result = jc.parse('xrandr', xrandr_command_output)
|
|
|
|
|
|
|
|
Schema:
|
2022-02-14 09:20:16 -08:00
|
|
|
|
|
|
|
{
|
|
|
|
"screens": [
|
|
|
|
{
|
|
|
|
"screen_number": integer,
|
|
|
|
"minimum_width": integer,
|
|
|
|
"minimum_height": integer,
|
|
|
|
"current_width": integer,
|
|
|
|
"current_height": integer,
|
|
|
|
"maximum_width": integer,
|
|
|
|
"maximum_height": integer,
|
2023-12-10 10:41:20 -08:00
|
|
|
"devices": [
|
|
|
|
{
|
2024-03-18 10:26:00 -07:00
|
|
|
"props": {
|
|
|
|
|
|
|
|
# either an EdidModel object or key value pairs
|
|
|
|
<key_name> : {
|
|
|
|
"name": string,
|
|
|
|
"product_id": string,
|
|
|
|
"serial_number": string,
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2024-02-12 15:05:44 -08:00
|
|
|
"resolution_modes": [
|
2023-12-10 10:41:20 -08:00
|
|
|
{
|
|
|
|
"resolution_width": integer,
|
|
|
|
"resolution_height": integer,
|
|
|
|
"is_high_resolution": boolean,
|
|
|
|
"frequencies": [
|
|
|
|
{
|
|
|
|
"frequency": float,
|
|
|
|
"is_current": boolean,
|
|
|
|
"is_preferred": boolean
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2022-02-14 09:20:16 -08:00
|
|
|
"is_connected": boolean,
|
|
|
|
"is_primary": boolean,
|
|
|
|
"device_name": string,
|
2023-02-21 17:19:17 -08:00
|
|
|
"model_name": string,
|
|
|
|
"product_id" string,
|
|
|
|
"serial_number": string,
|
2022-02-14 09:20:16 -08:00
|
|
|
"resolution_width": integer,
|
|
|
|
"resolution_height": integer,
|
|
|
|
"offset_width": integer,
|
|
|
|
"offset_height": integer,
|
|
|
|
"dimension_width": integer,
|
2022-04-10 18:19:29 +09:00
|
|
|
"dimension_height": integer,
|
2023-02-21 17:19:17 -08:00
|
|
|
"rotation": string,
|
|
|
|
"reflection": string
|
2022-02-14 09:20:16 -08:00
|
|
|
}
|
2023-12-10 13:13:57 -08:00
|
|
|
]
|
2022-02-14 09:20:16 -08:00
|
|
|
}
|
2022-02-14 09:14:46 -08:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2022-02-14 10:06:09 -08:00
|
|
|
$ xrandr | jc --xrandr -p
|
2022-02-14 10:03:52 -08:00
|
|
|
{
|
|
|
|
"screens": [
|
|
|
|
{
|
|
|
|
"screen_number": 0,
|
|
|
|
"minimum_width": 8,
|
|
|
|
"minimum_height": 8,
|
|
|
|
"current_width": 1920,
|
|
|
|
"current_height": 1080,
|
|
|
|
"maximum_width": 32767,
|
|
|
|
"maximum_height": 32767,
|
2023-12-10 10:41:20 -08:00
|
|
|
"devices": [
|
|
|
|
{
|
2024-02-12 15:05:44 -08:00
|
|
|
"resolution_modes": [
|
2023-12-10 10:41:20 -08:00
|
|
|
{
|
|
|
|
"resolution_width": 1920,
|
|
|
|
"resolution_height": 1080,
|
|
|
|
"is_high_resolution": false,
|
|
|
|
"frequencies": [
|
|
|
|
{
|
|
|
|
"frequency": 60.03,
|
|
|
|
"is_current": true,
|
|
|
|
"is_preferred": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"is_connected": true,
|
|
|
|
"is_primary": true,
|
|
|
|
"device_name": "eDP1",
|
|
|
|
"resolution_width": 1920,
|
|
|
|
"resolution_height": 1080,
|
|
|
|
"offset_width": 0,
|
|
|
|
"offset_height": 0,
|
|
|
|
"dimension_width": 310,
|
|
|
|
"dimension_height": 170,
|
|
|
|
"rotation": "normal",
|
|
|
|
"reflection": "normal"
|
|
|
|
}
|
|
|
|
]
|
2023-02-21 17:19:17 -08:00
|
|
|
}
|
2023-09-30 15:21:29 -07:00
|
|
|
]
|
2023-02-21 17:19:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
$ xrandr --properties | jc --xrandr -p
|
|
|
|
{
|
|
|
|
"screens": [
|
|
|
|
{
|
2023-12-10 10:41:20 -08:00
|
|
|
"devices": [
|
|
|
|
{
|
2024-03-18 10:26:00 -07:00
|
|
|
"props": {
|
|
|
|
"EDID": [
|
|
|
|
"00ffff5700000000",
|
|
|
|
"001c01a5544d9a27",
|
|
|
|
"0e50540101010101",
|
|
|
|
"010101383e401010",
|
|
|
|
"3500350f00000000",
|
|
|
|
"0000000000fe0041",
|
|
|
|
"554f0a20000000fe",
|
|
|
|
"00423137200a0070"
|
|
|
|
],
|
|
|
|
"scaling mode": [
|
|
|
|
"Full aspect ",
|
|
|
|
"supported: Full, Center, Full aspect"
|
|
|
|
],
|
|
|
|
"Colorspace": [
|
|
|
|
"Default ",
|
|
|
|
"supported: Default, RGB_Wide_Gamut_Fixed_Point, RGB_Wide_Gamut_Floating_Point, opRGB, DCI-P3_RGB_D65, BT2020_RGB, BT601_YCC, BT709_YCC, XVYCC_601, XVYCC_709, SYCC_601, opYCC_601, BT2020_CYCC, BT2020_YCC"
|
|
|
|
],
|
|
|
|
"EdidModel": {
|
|
|
|
"name": "Generic",
|
|
|
|
"product_id": "22333",
|
|
|
|
"serial_number": "0"
|
|
|
|
}
|
|
|
|
},
|
2024-02-12 15:05:44 -08:00
|
|
|
"resolution_modes": [
|
2023-12-10 10:41:20 -08:00
|
|
|
{
|
2024-03-18 10:26:00 -07:00
|
|
|
"resolution_width": 320,
|
|
|
|
"resolution_height": 180,
|
2023-12-10 10:41:20 -08:00
|
|
|
"is_high_resolution": false,
|
|
|
|
"frequencies": [
|
|
|
|
{
|
2024-03-18 10:26:00 -07:00
|
|
|
"frequency": 59.84,
|
2023-12-10 10:41:20 -08:00
|
|
|
"is_current": false,
|
|
|
|
"is_preferred": false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"is_connected": true,
|
|
|
|
"is_primary": true,
|
2024-03-18 10:26:00 -07:00
|
|
|
"device_name": "eDP-1",
|
|
|
|
"rotation": "normal",
|
|
|
|
"reflection": "normal",
|
2023-12-10 10:41:20 -08:00
|
|
|
"resolution_width": 1920,
|
|
|
|
"resolution_height": 1080,
|
|
|
|
"offset_width": 0,
|
|
|
|
"offset_height": 0,
|
2024-03-18 10:26:00 -07:00
|
|
|
"dimension_width": 309,
|
|
|
|
"dimension_height": 174
|
2023-12-10 10:41:20 -08:00
|
|
|
}
|
2024-03-18 10:26:00 -07:00
|
|
|
],
|
|
|
|
"screen_number": 0,
|
|
|
|
"minimum_width": 320,
|
|
|
|
"minimum_height": 200,
|
|
|
|
"current_width": 1920,
|
|
|
|
"current_height": 1080,
|
|
|
|
"maximum_width": 16384,
|
|
|
|
"maximum_height": 16384
|
2022-02-14 10:03:52 -08:00
|
|
|
}
|
2023-09-30 15:21:29 -07:00
|
|
|
]
|
2022-02-14 10:03:52 -08:00
|
|
|
}
|
2022-02-14 09:14:46 -08:00
|
|
|
|
|
|
|
<a id="jc.parsers.xrandr.parse"></a>
|
|
|
|
|
2022-03-05 12:15:14 -08:00
|
|
|
### parse
|
2022-02-14 09:14:46 -08:00
|
|
|
|
|
|
|
```python
|
2024-03-14 22:46:52 -07:00
|
|
|
def parse(data: str,
|
|
|
|
raw: bool = False,
|
|
|
|
quiet: bool = False) -> jc.parsers.xrandr.Response
|
2022-02-14 09:14:46 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) unprocessed output if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
2022-02-14 10:03:52 -08:00
|
|
|
Dictionary. Raw or processed structured data.
|
2022-02-14 09:14:46 -08:00
|
|
|
|
|
|
|
### Parser Information
|
|
|
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
|
|
|
|
2023-12-21 14:55:21 -08:00
|
|
|
Source: [`jc/parsers/xrandr.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/xrandr.py)
|
|
|
|
|
2024-03-18 10:26:00 -07:00
|
|
|
Version 2.1 by Kevin Lyter (code (at) lyterk.com)
|