Skip to content

Commit

Permalink
fix(GeneralSettings): Add driver, kernel, and BIOS information to Gen…
Browse files Browse the repository at this point in the history
…eral 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
  • Loading branch information
Sterophonick authored Sep 5, 2023
1 parent 74a4c82 commit 611f09d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 10 deletions.
41 changes: 35 additions & 6 deletions core/global/platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions core/ui/card_ui/settings/general_settings_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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":
Expand Down
25 changes: 23 additions & 2 deletions core/ui/card_ui/settings/general_settings_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -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")]
4 changes: 2 additions & 2 deletions core/ui/components/text.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 611f09d

Please sign in to comment.