Commit 7d11f6ac authored by intrigeri's avatar intrigeri

Fix sorting Intel GPUs last in the "Error starting GDM" message (#17903)

The argument passed to sort_gpus() looks like this:

  [{'Slot': '00:02.0',
    'Class': 'VGA compatible controller [0300]',
    'Vendor-code': '8086',
    'Vendor': 'Intel Corporation',
    'Device-code': '5917',
    'Device': 'UHD Graphics 620',
    'SVendor': 'Lenovo [17aa]',
    'SDevice': 'UHD Graphics 620 [225c]',
    'Rev': '07'}]

So sorting the list based on whether the Vendor ends with "[8086]" did not do
what we want, i.e. sort Intel GPUs last (which we do because the Plymouth
message will be truncated, and we want to display the most relevant GPUs first,
which usually are not the Intel integrated GPU).
parent fff3fb0f
......@@ -88,14 +88,14 @@ def sort_gpus(gpus: list) -> list:
Sort GPUs putting the most probable at top.
Specifically, this means putting Intel last.
>>> gpus = [{"Vendor": "Intel Corporation [8086]"}, {"Vendor": "Anyone"}]
>>> sort_gpus(gpus)[0]["Vendor"]
>>> gpus = [{"Vendor-code": "8086"}, {"Vendor-code": "1234"}]
>>> sort_gpus(gpus)[0]["Vendor-code"]
>>> gpus.reverse()
>>> sort_gpus(gpus)[0]["Vendor"]
>>> sort_gpus(gpus)[0]["Vendor-code"]
return sorted(gpus, key=lambda g: g["Vendor"].endswith("[8086]"))
return sorted(gpus, key=lambda g: g["Vendor-code"] == "8086")
def format_gpus(gpus: list) -> str:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment