From 611f09ded111ac3081a9b562d813bd4a289a101d Mon Sep 17 00:00:00 2001 From: Atapi <34801996+Sterophonick@users.noreply.github.com> Date: Mon, 4 Sep 2023 23:11:34 -0600 Subject: [PATCH] fix(GeneralSettings): Add driver, kernel, and BIOS information to General Settings (#246) * add mesa and kernel version to general settings menu * add BIOS version to settings menu * remove pointless filler function * tweak commenting * tweak layout * move vendor up because it makes more sense --- core/global/platform.gd | 41 ++++++++++++++++--- .../card_ui/settings/general_settings_menu.gd | 6 +++ .../settings/general_settings_menu.tscn | 25 ++++++++++- core/ui/components/text.tscn | 4 +- 4 files changed, 66 insertions(+), 10 deletions(-) diff --git a/core/global/platform.gd b/core/global/platform.gd index 23c6cc09..483027cc 100644 --- a/core/global/platform.gd +++ b/core/global/platform.gd @@ -50,7 +50,8 @@ var platform: PlatformProvider var logger := Log.get_logger("Platform", Log.LEVEL.INFO) var cpu: CPUInfo var gpu: GPUInfo - +var kernel: String +var bios: String func _init() -> void: amd_apu_database = load("res://core/platform/hardware/amd_apu_database.tres") @@ -175,10 +176,17 @@ func get_cpu_model() -> String: func get_gpu_info() -> GPUInfo: return gpu - func get_gpu_model() -> String: return gpu.model + +func get_gpu_driver() -> String: + return gpu.driver + +func get_kernel_version() -> String: + return kernel +func get_bios_version() -> String: + return bios ## Used to read values from sysfs func _read_sys(path: String) -> String: @@ -322,7 +330,8 @@ func _detect_os() -> OSInfo: func _get_system_components(): cpu = _read_cpu_info() gpu = _read_gpu_info() - + kernel = _get_kernel_version() + bios = _get_bios_version() # Provides info on the CPU vendor, model, and capabilities. func _read_cpu_info() -> CPUInfo: @@ -368,7 +377,7 @@ func _read_gpu_info() -> GPUInfo: var gpu_info := GPUInfo.new() var gpu_raw := _get_glxinfo() - # Get the GPU Vendor and Model + # Get the GPU Vendor, Model, and Driver for param in gpu_raw: var parts := param.split(" ", false) as Array if parts.is_empty(): @@ -383,6 +392,11 @@ func _read_gpu_info() -> GPUInfo: parts.remove_at(1) parts.remove_at(0) gpu_info.model = str(" ".join(parts)) + if parts[0] == "OpenGL" and parts[1] == "version" and parts[2] == "string:": + parts.remove_at(2) + parts.remove_at(1) + parts.remove_at(0) + gpu_info.driver = str(" ".join(parts)) logger.debug("Found GPU: Vendor: " + gpu_info.vendor + "Model: " + gpu_info.model) if not cpu: @@ -412,7 +426,6 @@ func _read_gpu_info() -> GPUInfo: return gpu_info - # Run glxinfo and return the data from it. # TODO: Maybe use vulkaninfo? Need a way to get vendor string in that. It can # output to JSON so it might be easier to get more info like driver name and info, @@ -424,7 +437,22 @@ func _get_glxinfo() -> Array: if exit_code: return [] return output[0][0].split("\n") as Array - + +# Run uname and return the data from it. +func _get_kernel_version() -> String: + var output: Array = _do_exec("uname", ["-s", "-r", "-m"]) # Fetches kernel name, version, and machine + var exit_code = output[1] + if exit_code: + return "Unknown" + return output[0][0] as String + +# Queries /sys/class for BIOS information +func _get_bios_version() -> String: + var output: Array = _do_exec("cat", ["/sys/class/dmi/id/bios_version"]) + var exit_code = output[1] + if exit_code: + return "Unknown" + return output[0][0] as String ## Data container for OS information class OSInfo extends Resource: @@ -448,6 +476,7 @@ class CPUInfo extends Resource: class GPUInfo extends Resource: var model: String var vendor: String + var driver: String var tdp_capable: bool = false var thermal_profile_capable: bool = false var tj_temp_capable: bool = false diff --git a/core/ui/card_ui/settings/general_settings_menu.gd b/core/ui/card_ui/settings/general_settings_menu.gd index f07bd150..db9f3fdd 100644 --- a/core/ui/card_ui/settings/general_settings_menu.gd +++ b/core/ui/card_ui/settings/general_settings_menu.gd @@ -28,6 +28,9 @@ var logger := Log.get_logger("GeneralSettings") @onready var vendor_text := $%VendorText @onready var cpu_text := $%CPUModelText @onready var gpu_text := $%GPUModelText +@onready var driver_text := $%GPUDriverText +@onready var kernel_text := $%KernelVerText +@onready var bios_text := $%BIOSVerText # Called when the node enters the scene tree for the first time. @@ -39,6 +42,9 @@ func _ready() -> void: vendor_text.text = Platform.get_vendor_name() cpu_text.text = Platform.get_cpu_model() gpu_text.text = Platform.get_gpu_model() + driver_text.text = Platform.get_gpu_driver() + kernel_text.text = Platform.get_kernel_version() + bios_text.text = Platform.get_bios_version() # Try to detect the platform and platform image if product_text.text == "Jupiter" and vendor_text.text == "Valve": diff --git a/core/ui/card_ui/settings/general_settings_menu.tscn b/core/ui/card_ui/settings/general_settings_menu.tscn index 508d39dc..6024b34b 100644 --- a/core/ui/card_ui/settings/general_settings_menu.tscn +++ b/core/ui/card_ui/settings/general_settings_menu.tscn @@ -189,10 +189,10 @@ title = "OS" description = "" text = "Generic" -[node name="ProductText" parent="MarginContainer/VBoxContainer/VBoxContainer3" instance=ExtResource("9_sq2rc")] +[node name="KernelVerText" parent="MarginContainer/VBoxContainer/VBoxContainer3" instance=ExtResource("9_sq2rc")] unique_name_in_owner = true layout_mode = 2 -title = "Product" +title = "Kernel Version" description = "" text = "Generic" @@ -203,6 +203,20 @@ title = "Vendor" description = "" text = "Generic" +[node name="ProductText" parent="MarginContainer/VBoxContainer/VBoxContainer3" instance=ExtResource("9_sq2rc")] +unique_name_in_owner = true +layout_mode = 2 +title = "Product" +description = "" +text = "Generic" + +[node name="BIOSVerText" parent="MarginContainer/VBoxContainer/VBoxContainer3" instance=ExtResource("9_sq2rc")] +unique_name_in_owner = true +layout_mode = 2 +title = "BIOS Version" +description = "" +text = "Generic" + [node name="CPUModelText" parent="MarginContainer/VBoxContainer/VBoxContainer3" instance=ExtResource("9_sq2rc")] unique_name_in_owner = true layout_mode = 2 @@ -217,4 +231,11 @@ title = "GPU Model" description = "" text = "Generic" +[node name="GPUDriverText" parent="MarginContainer/VBoxContainer/VBoxContainer3" instance=ExtResource("9_sq2rc")] +unique_name_in_owner = true +layout_mode = 2 +title = "Driver Version" +description = "" +text = "Generic" + [node name="ScrollerJoystick" parent="." instance=ExtResource("10_06mt3")] diff --git a/core/ui/components/text.tscn b/core/ui/components/text.tscn index a46bf353..215e54ee 100644 --- a/core/ui/components/text.tscn +++ b/core/ui/components/text.tscn @@ -4,7 +4,7 @@ [ext_resource type="Script" path="res://core/ui/components/text.gd" id="1_lo12x"] [ext_resource type="LabelSettings" uid="uid://bv56n31s84bfn" path="res://assets/label/subheading_label.tres" id="2_mq5ej"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vu8be"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_81u1n"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -29,7 +29,7 @@ script = ExtResource("1_lo12x") [node name="PanelContainer" type="PanelContainer" parent="."] unique_name_in_owner = true layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_vu8be") +theme_override_styles/panel = SubResource("StyleBoxFlat_81u1n") [node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"] layout_mode = 2