Skip to content

Commit

Permalink
cs-info: Better parsing of the graphics card lspci output
Browse files Browse the repository at this point in the history
- Some cards show up as "3D controller", not just
"VGA compatible controller".
- Don't split according to semicolumn, it's prone to errors. Instead
split using the already matched prefix (VGA compatible controller
or 3D controller).

Fixes #12240
Fixes linuxmint/mint22-beta#7
  • Loading branch information
clefebvre committed Jul 4, 2024
1 parent 62d50ef commit e0f64fb
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ def getGraphicsInfos():
envpath = os.environ["PATH"]
os.environ["PATH"] = envpath + ":/usr/local/sbin:/usr/sbin:/sbin"
for card in getProcessOut("lspci"):
if not "VGA" in card:
continue
cardId = card.split()[0]
cardName = None
for line in getProcessOut(("lspci", "-v", "-s", cardId)):
if line.startswith(cardId):
cardName = (line.split(":")[2].split("(rev")[0].strip())

if cardName:
cards[count] = cardName
count += 1
for prefix in ["VGA compatible controller:", "3D controller:"]:
if prefix in card:
cardName = card.split(prefix)[1].split("(rev")[0].strip()
cards[count] = cardName
count += 1
os.environ["PATH"] = envpath
return cards

Expand Down

0 comments on commit e0f64fb

Please sign in to comment.