Skip to content

Commit 0b90ff3

Browse files
committed
fix(PowerStation): Get power profiles from PowerStation
- Uses dbus to read the available power profiles from PowerStation - Renamed PowerTools to Performance and moved everything from the old performance menu into it. - Adds "Advanced Mode" toggle to display CPU and GPU settings. Only the power profile will be displayed when this is set to off (default). When on, power profile is forced to the highest performance profile. If PowerStation is using RyzenAdj to set TDP, "max-performance" will sett all TDP to the hardware max milit, and "power-saving" will set all TDP to the mid point between max and min.
1 parent 35bc895 commit 0b90ff3

File tree

16 files changed

+631
-559
lines changed

16 files changed

+631
-559
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://xw3l4h1vt0oa"]
1+
[gd_resource type="Resource" script_class="State" load_steps=2 format=3 uid="uid://b2ruoxboq5k6e"]
22

3-
[ext_resource type="Script" path="res://core/systems/state/state.gd" id="1_pmemp"]
3+
[ext_resource type="Script" path="res://core/systems/state/state.gd" id="1_3a3in"]
44

55
[resource]
6-
script = ExtResource("1_pmemp")
7-
name = "performance"
6+
script = ExtResource("1_3a3in")
7+
name = "powertools"
88
data = null

assets/state/states/quick_bar_powertools.tres

Lines changed: 0 additions & 8 deletions
This file was deleted.

assets/ui/icons/powertools_icon.svg.import renamed to assets/ui/icons/performance_icon.svg.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://cqy34r7oni6d4"
6-
path="res://.godot/imported/powertools_icon.svg-652cf7833e5f111e096aaec7055e1d3a.ctex"
6+
path="res://.godot/imported/performance_icon.svg-5082e7fb3c41a1711d81bab95097ecfa.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://assets/ui/icons/powertools_icon.svg"
14-
dest_files=["res://.godot/imported/powertools_icon.svg-652cf7833e5f111e096aaec7055e1d3a.ctex"]
13+
source_file="res://assets/ui/icons/performance_icon.svg"
14+
dest_files=["res://.godot/imported/performance_icon.svg-5082e7fb3c41a1711d81bab95097ecfa.ctex"]
1515

1616
[params]
1717

core/systems/performance/performance_manager.gd

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,16 @@ func create_profile(library_item: LibraryLaunchItem = null) -> PerformanceProfil
117117
for card in cards:
118118
if card.class != "integrated":
119119
continue
120-
121-
profile.tdp_current = card.tdp
122-
profile.tdp_boost_current = card.boost
120+
if _hardware_manager.gpu:
121+
profile.tdp_current = round(_hardware_manager.gpu.tdp_max)
122+
profile.tdp_boost_current = round(_hardware_manager.gpu.max_boost)
123+
else:
124+
profile.tdp_current = card.tdp
125+
profile.tdp_boost_current = card.boost
123126
profile.gpu_freq_min_current = card.clock_value_mhz_min
124127
profile.gpu_freq_max_current = card.clock_value_mhz_max
125128
profile.gpu_manual_enabled = card.manual_clock
126-
#profile.gpu_power_profile = card.power_profile # TODO: Fix this
129+
profile.gpu_power_profile = card.power_profile
127130
profile.gpu_temp_current = card.thermal_throttle_limit_c
128131

129132
logger.debug("Created performance profile: " + profile.name)
@@ -177,23 +180,12 @@ func apply_profile(profile: PerformanceProfile) -> void:
177180
if card.class != "integrated":
178181
continue
179182
logger.debug("Applying GPU performance settings from profile")
180-
if profile.gpu_power_profile >= 0:
181-
var power_profile := "max-performance"
182-
if profile.gpu_power_profile == 0:
183-
power_profile = "max-performance"
184-
if profile.gpu_power_profile == 1:
185-
power_profile = "power-saving"
186-
if card.power_profile != power_profile:
187-
logger.debug("Applying Power Profile: " + power_profile)
188-
card.power_profile = power_profile
183+
if card.power_profile != profile.gpu_power_profile:
184+
logger.debug("Applying Power Profile: " + profile.gpu_power_profile)
185+
card.power_profile = profile.gpu_power_profile
189186
if card.manual_clock != profile.gpu_manual_enabled:
187+
logger.debug("Applying Manual Clock Enabled: " + str(profile.gpu_manual_enabled))
190188
card.manual_clock = profile.gpu_manual_enabled
191-
if profile.tdp_current > 0 and card.tdp != profile.tdp_current:
192-
logger.debug("Applying TDP: " + str(profile.tdp_current))
193-
card.tdp = profile.tdp_current
194-
if profile.tdp_boost_current > 0 and card.boost != profile.tdp_boost_current:
195-
logger.debug("Applying TDP Boost: " + str(profile.tdp_boost_current))
196-
card.boost = profile.tdp_boost_current
197189
if profile.gpu_freq_min_current > 0 and card.clock_value_mhz_min != profile.gpu_freq_min_current:
198190
logger.debug("Applying Clock Freq Min: " + str(profile.gpu_freq_min_current))
199191
card.clock_value_mhz_min = profile.gpu_freq_min_current
@@ -204,6 +196,15 @@ func apply_profile(profile: PerformanceProfile) -> void:
204196
logger.debug("Applying Thermal Throttle Limit: " + str(profile.gpu_temp_current))
205197
card.thermal_throttle_limit_c = profile.gpu_temp_current
206198

199+
# Only apply GPU TDP settings from the given profile if we're in a mode that supports it
200+
if profile.advanced_mode or "max-performance" in get_power_profiles_available():
201+
if profile.tdp_current > 0 and card.tdp != profile.tdp_current:
202+
logger.debug("Applying TDP: " + str(profile.tdp_current))
203+
card.tdp = profile.tdp_current
204+
if profile.tdp_boost_current > 0 and card.boost != profile.tdp_boost_current:
205+
logger.debug("Applying TDP Boost: " + str(profile.tdp_boost_current))
206+
card.boost = profile.tdp_boost_current
207+
207208
# Apply CPU settings from the given profile
208209
if _power_station.cpu:
209210
logger.debug("Applying CPU performance settings from profile")
@@ -299,3 +300,18 @@ func _on_app_switched(_from: RunningApp, to: RunningApp) -> void:
299300
current_profile = profile
300301
profile_loaded.emit(profile)
301302
apply_profile(profile)
303+
304+
305+
# Get the currently available power profiles
306+
func get_power_profiles_available() -> PackedStringArray:
307+
# Detect all GPU cards
308+
var cards: Array[GpuCard] = []
309+
if _power_station.gpu:
310+
cards = _power_station.gpu.get_cards()
311+
312+
for card in cards:
313+
if card.class != "integrated":
314+
continue
315+
316+
return card.power_profiles_available
317+
return []

core/systems/performance/performance_profile.gd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ class_name PerformanceProfile
1010
@export var gpu_freq_max_current: float
1111
@export var gpu_freq_min_current: float
1212
@export var gpu_manual_enabled: bool
13-
@export var gpu_power_profile: int
13+
@export var gpu_power_profile: String
1414
@export var gpu_temp_current: float
1515
@export var tdp_boost_current: float
1616
@export var tdp_current: float
1717
@export var thermal_profile: int
18+
@export var advanced_mode: bool = false
1819

1920

2021
func _to_string() -> String:
@@ -25,8 +26,9 @@ func _to_string() -> String:
2526
+ "gpu_freq_max_current: " + str(gpu_freq_max_current) + ", " \
2627
+ "gpu_freq_min_current: " + str(gpu_freq_min_current) + ", " \
2728
+ "gpu_manual_enabled: " + str(gpu_manual_enabled) + ", " \
28-
+ "gpu_power_profile: " + str(gpu_power_profile) + ", " \
29+
+ "gpu_power_profile: " + gpu_power_profile + ", " \
2930
+ "gpu_temp_current: " + str(gpu_temp_current) + ", " \
3031
+ "tdp_boost_current: " + str(tdp_boost_current) + ", " \
3132
+ "tdp_current: " + str(tdp_current) + ", " \
32-
+ "thermal_profile: " + str(thermal_profile) + ">"
33+
+ "thermal_profile: " + str(thermal_profile) + ", " \
34+
+ "advanced_mode:" + str(advanced_mode) + ">"
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
1-
[gd_scene load_steps=5 format=3 uid="uid://dycb7m0oj13ly"]
1+
[gd_scene load_steps=3 format=3 uid="uid://dycb7m0oj13ly"]
22

33
[ext_resource type="PackedScene" uid="uid://b5xnora73yd8x" path="res://core/ui/card_ui/quick_bar/qb_card.tscn" id="1_77cql"]
4-
[ext_resource type="PackedScene" uid="uid://b7piua3snox4i" path="res://core/ui/common/quick_bar/performance_menu.tscn" id="2_k3j2r"]
5-
6-
[sub_resource type="Image" id="Image_asnwl"]
7-
data = {
8-
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
9-
"format": "RGBA8",
10-
"height": 16,
11-
"mipmaps": false,
12-
"width": 16
13-
}
14-
15-
[sub_resource type="ImageTexture" id="ImageTexture_adlkc"]
16-
image = SubResource("Image_asnwl")
4+
[ext_resource type="PackedScene" uid="uid://dv3dt0j3jketh" path="res://core/ui/common/quick_bar/performance_menu.tscn" id="3_e67l3"]
175

186
[node name="PerformanceCard" instance=ExtResource("1_77cql")]
197
title = "Performance"
208

21-
[node name="HighlightTexture" parent="." index="4"]
22-
texture = SubResource("ImageTexture_adlkc")
23-
249
[node name="SectionLabel" parent="MarginContainer/CardVBoxContainer" index="0"]
2510
text = "Performance"
2611

27-
[node name="PerformanceMenu" parent="MarginContainer/CardVBoxContainer/ContentContainer" index="0" instance=ExtResource("2_k3j2r")]
12+
[node name="Performance" parent="MarginContainer/CardVBoxContainer/ContentContainer" index="0" instance=ExtResource("3_e67l3")]
2813
layout_mode = 2
14+
size_flags_vertical = 0

core/ui/card_ui/quick_bar/power_tools_card.tscn

Lines changed: 0 additions & 29 deletions
This file was deleted.

core/ui/card_ui/quick_bar/quick_bar_menu.tscn

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=31 format=3 uid="uid://hroo3ll4inrb"]
1+
[gd_scene load_steps=30 format=3 uid="uid://hroo3ll4inrb"]
22

33
[ext_resource type="Script" path="res://core/ui/card_ui/quick_bar/quick_bar_menu.gd" id="1_56jo7"]
44
[ext_resource type="PackedScene" uid="uid://shvyhrv5sx3v" path="res://core/systems/state/state_watcher.tscn" id="2_6rvrx"]
@@ -29,7 +29,6 @@
2929
[ext_resource type="PackedScene" uid="uid://bjy50kdrebgre" path="res://core/ui/card_ui/quick_bar/notifications_card.tscn" id="19_pppbi"]
3030
[ext_resource type="PackedScene" uid="uid://dxaeufuk7ump2" path="res://core/ui/card_ui/quick_bar/quick_settings_card.tscn" id="20_17ks0"]
3131
[ext_resource type="PackedScene" uid="uid://dycb7m0oj13ly" path="res://core/ui/card_ui/quick_bar/performance_card.tscn" id="21_uw510"]
32-
[ext_resource type="PackedScene" uid="uid://v751ima8r8vg" path="res://core/ui/card_ui/quick_bar/power_tools_card.tscn" id="22_dtanu"]
3332

3433
[node name="QuickBarMenu" type="Control" groups=["quick-bar"]]
3534
z_index = 20
@@ -236,6 +235,3 @@ layout_mode = 2
236235

237236
[node name="PerformanceCard" parent="MarginContainer/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/Viewport" instance=ExtResource("21_uw510")]
238237
layout_mode = 2
239-
240-
[node name="PowerToolsCard" parent="MarginContainer/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/Viewport" instance=ExtResource("22_dtanu")]
241-
layout_mode = 2

0 commit comments

Comments
 (0)