Skip to content

Commit eb6ad65

Browse files
mihawk90RytoEX
authored andcommitted
linux: Unify system info summary
Currently Linux logs output (typically) 3 separate bullet points for the system information (Distro, Display Server, Desktop Environment), which looks odd and lengthens the page or bot summary. Since all are merely informational and without help texts, this combines all 3 points into a single one. The Flatpak extension helptext is shown alongside it when appropriate. For this I chose to extract the simple X11/Wayland checks into their own functions to make them reusable in other check functions.
1 parent e1512e5 commit eb6ad65

File tree

2 files changed

+71
-34
lines changed

2 files changed

+71
-34
lines changed

checks/linux.py

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@ def getWindowSystemLine(lines):
1414
return windowSystem[0]
1515

1616

17+
def isWayland(lines):
18+
if not (checkDistro(lines) or checkFlatpak(lines)):
19+
return False
20+
21+
sessionTypeLine = getSessionTypeLine(lines)
22+
if not sessionTypeLine:
23+
return False
24+
25+
if 'wayland' not in sessionTypeLine:
26+
return False
27+
28+
return True
29+
30+
31+
def isX11(lines):
32+
if not (checkDistro(lines) or checkFlatpak(lines)):
33+
return False
34+
35+
sessionTypeLine = getSessionTypeLine(lines)
36+
if not sessionTypeLine:
37+
return False
38+
39+
if 'x11' not in sessionTypeLine:
40+
return False
41+
42+
return True
43+
44+
1745
def checkDistro(lines):
1846
isDistroNix = search('Distribution:', lines)
1947

@@ -47,23 +75,13 @@ def checkSnapPackage(lines):
4775

4876

4977
def checkWayland(lines):
50-
isDistroNix = search('Distribution:', lines)
51-
isFlatpak = search('Flatpak Runtime:', lines)
52-
53-
if (len(isDistroNix) <= 0) and (len(isFlatpak) <= 0):
54-
return
55-
56-
sessionTypeLine = getSessionTypeLine(lines)
57-
if not sessionTypeLine:
58-
return
59-
60-
if 'wayland' not in sessionTypeLine:
78+
if not isWayland(lines):
6179
return
6280

63-
if len(isDistroNix) > 0:
64-
if '"Ubuntu" "20.04"' in isDistroNix[0]:
65-
return [LEVEL_CRITICAL, "Ubuntu 20.04 under Wayland",
66-
"Ubuntu 20.04 does not provide the needed dependencies for OBS to capture under Wayland.<br> Capture will only function under X11/Xorg."]
81+
isDistroNix = checkDistro(lines)
82+
if isDistroNix and ('"Ubuntu" "20.04"' in isDistroNix[1]):
83+
return [LEVEL_CRITICAL, "Ubuntu 20.04 under Wayland",
84+
"Ubuntu 20.04 does not provide the needed dependencies for OBS to capture under Wayland.<br> Capture will only function under X11/Xorg."]
6785

6886
windowSystemLine = getWindowSystemLine(lines)
6987
# If there is no Window System, OBS is running under Wayland
@@ -80,21 +98,9 @@ def checkWayland(lines):
8098
<a href='https://wiki.archlinux.org/title/XDG_Desktop_Portal'>XDG Desktop Portal</a><br>
8199
Note that the availability of Window and/or Display capture depends on your Desktop Environment's implementation of these portals."""]
82100

83-
return [LEVEL_INFO, "Wayland", ""]
84-
85101

86102
def checkX11Captures(lines):
87-
isDistroNix = search('Distribution:', lines)
88-
isFlatpak = search('Flatpak Runtime:', lines)
89-
90-
if (len(isDistroNix) <= 0) and (len(isFlatpak) <= 0):
91-
return
92-
93-
sessionTypeLine = getSessionTypeLine(lines)
94-
if not sessionTypeLine:
95-
return
96-
97-
if 'x11' not in sessionTypeLine:
103+
if not isX11(lines):
98104
return
99105

100106
# obsolete PW sources
@@ -108,8 +114,6 @@ def checkX11Captures(lines):
108114
"""Most Desktop Environments do not implement the PipeWire capture portals on X11. This can result in being unable to pick a window or display, or the selected source will stay empty.<br><br>
109115
We generally recommend using \"Window Capture (Xcomposite)\" on X11, as \"Display Capture (XSHM)\" can introduce bottlenecks depending on your setup."""]
110116

111-
return [LEVEL_INFO, "X11", ""]
112-
113117

114118
def checkDesktopEnvironment(lines):
115119
isDistroNix = search('Distribution:', lines)
@@ -119,6 +123,10 @@ def checkDesktopEnvironment(lines):
119123
return
120124

121125
desktopEnvironmentLine = search('Desktop Environment:', lines)
126+
127+
if not desktopEnvironmentLine:
128+
return
129+
122130
desktopEnvironment = desktopEnvironmentLine[0].split()
123131

124132
if (len(desktopEnvironment) > 3):
@@ -167,3 +175,34 @@ def checkLinuxVCam(lines):
167175
return [LEVEL_INFO, "Virtual Camera not available",
168176
"""Using the Virtual Camera requires the <code>v4l2loopback</code> kernel module to be installed.<br>
169177
If required, please refer to our <a href="https://github.com/obsproject/obs-studio/wiki/install-instructions#prerequisites-for-all-versions">Install Instructions</a> on how to install this on your distribution."""]
178+
179+
180+
def checkLinuxSystemInfo(lines):
181+
if checkFlatpak(lines):
182+
linuxDistroOrFlatpak = 'Flatpak'
183+
linuxSystemInfoHelp = checkFlatpak(lines)[2] + '<br>'
184+
elif checkDistro(lines):
185+
linuxDistroOrFlatpak = 'Distribution: ' + checkDistro(lines)[1]
186+
linuxSystemInfoHelp = ''
187+
else:
188+
# I have never seen this, but you never know
189+
linuxDistroOrFlatpak = 'Distribution: ⚠️ None'
190+
linuxSystemInfoHelp = 'No distribution detected. This can lead to undefined behaviour. Please consult your distribution\'s support channels on how to fix this.<br>'
191+
192+
if isX11(lines):
193+
displayServer = 'X11'
194+
elif isWayland(lines):
195+
displayServer = 'Wayland'
196+
else:
197+
# can happen with misconfigured or virtual systems
198+
displayServer = '⚠️ None'
199+
linuxSystemInfoHelp += 'No Display Server detected. This can lead to undefined behaviour. Please consult your Desktop Environment\'s or Window Manager\'s support channels on how to fix this.<br>'
200+
201+
if checkDesktopEnvironment(lines):
202+
desktopEnvironment = 'DE: ' + checkDesktopEnvironment(lines)[1]
203+
else:
204+
# can happen for some misconfigured tiling window managers
205+
desktopEnvironment = 'DE: ⚠️ None'
206+
linuxSystemInfoHelp += 'No Desktop Environment detected. This can lead to undefined behaviour. Please consult your Desktop Environment\'s or Window Manager\'s support channels on how to fix this.'
207+
208+
return [LEVEL_INFO, linuxDistroOrFlatpak + ' | ' + displayServer + ' | ' + desktopEnvironment, linuxSystemInfoHelp]

loganalyzer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,13 @@ def doAnalysis(url=None, filename=None):
182182
checkVantage(logLines),
183183
checkPortableMode(logLines),
184184
checkSafeMode(logLines),
185-
checkDistro(logLines),
186-
checkFlatpak(logLines),
187185
checkSnapPackage(logLines),
188186
checkX11Captures(logLines),
189-
checkDesktopEnvironment(logLines),
190187
checkMissingModules(logLines),
191188
checkLinuxVCam(logLines),
192189
checkMacPermissions(logLines),
193-
checkServiceRecommendations(logLines)
190+
checkServiceRecommendations(logLines),
191+
checkLinuxSystemInfo(logLines)
194192
])
195193
messages.extend(checkVideoSettings(logLines))
196194
m = parseScenes(logLines)

0 commit comments

Comments
 (0)