Skip to content

Commit

Permalink
parts/displays: set max bpc of all outputs with one xrandr call
Browse files Browse the repository at this point in the history
Makes setting max bpc so much faster.
  • Loading branch information
tuomasjjrasanen committed Feb 2, 2024
1 parent 7080e82 commit 45b0105
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions parts/displays/puavodisplays/xrandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,18 @@ def get_prop() -> typing.Dict[str, typing.Dict[str, typing.Any]]:
return xrandr_prop_output_parser.parse(xrandr_prop_output)


def set_max_bpc(output_name: str, max_bpc: int) -> None:
"""Set max bpc of a display output"""
_call_xrandr(
[
"--output",
output_name,
"--set",
"max bpc",
str(max_bpc),
]
)
def set_max_bpc(max_bpc_per_output: typing.Dict[str, int]) -> None:
"""Set max bpc of display outputs."""
xrandr_args = []

for output_name, max_bpc in max_bpc_per_output.items():
xrandr_args.append("--output")
xrandr_args.append(output_name)
xrandr_args.append("--set")
xrandr_args.append("max bpc")
xrandr_args.append(str(max_bpc))

_call_xrandr(xrandr_args)


def set_max_bpc_of_all_display_outputs(
Expand All @@ -265,6 +266,8 @@ def set_max_bpc_of_all_display_outputs(
If logger is defined, it is used for logging the progress.
"""

max_bpc_per_output = {}

for output_name, output in get_prop().items():
if "max bpc" in output["props"]:
if logger:
Expand All @@ -287,13 +290,13 @@ def set_max_bpc_of_all_display_outputs(
value_min,
value_max,
)

set_max_bpc(output_name, new_value)

if logger:
logger.info(
"set max bpc of %r from %d to %d",
"setting max bpc of %r from %d to %d",
output_name,
current_value,
new_value,
)
max_bpc_per_output[output_name] = new_value

set_max_bpc(max_bpc_per_output)

0 comments on commit 45b0105

Please sign in to comment.