Skip to content

Commit edf2ef2

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 edf2ef2

File tree

16 files changed

+624
-555
lines changed

16 files changed

+624
-555
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: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,12 @@ func apply_profile(profile: PerformanceProfile) -> void:
177177
if card.class != "integrated":
178178
continue
179179
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
180+
if card.power_profile != profile.gpu_power_profile:
181+
logger.debug("Applying Power Profile: " + profile.gpu_power_profile)
182+
card.power_profile = profile.gpu_power_profile
189183
if card.manual_clock != profile.gpu_manual_enabled:
184+
logger.debug("Applying Manual Clock Enabled: " + str(profile.gpu_manual_enabled))
190185
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
197186
if profile.gpu_freq_min_current > 0 and card.clock_value_mhz_min != profile.gpu_freq_min_current:
198187
logger.debug("Applying Clock Freq Min: " + str(profile.gpu_freq_min_current))
199188
card.clock_value_mhz_min = profile.gpu_freq_min_current
@@ -204,6 +193,15 @@ func apply_profile(profile: PerformanceProfile) -> void:
204193
logger.debug("Applying Thermal Throttle Limit: " + str(profile.gpu_temp_current))
205194
card.thermal_throttle_limit_c = profile.gpu_temp_current
206195

196+
# Only apply GPU TDP settings from the given profile if we're in a mode that supports it
197+
if profile.advanced_mode or "max-performance" in get_power_profiles_available():
198+
if profile.tdp_current > 0 and card.tdp != profile.tdp_current:
199+
logger.debug("Applying TDP: " + str(profile.tdp_current))
200+
card.tdp = profile.tdp_current
201+
if profile.tdp_boost_current > 0 and card.boost != profile.tdp_boost_current:
202+
logger.debug("Applying TDP Boost: " + str(profile.tdp_boost_current))
203+
card.boost = profile.tdp_boost_current
204+
207205
# Apply CPU settings from the given profile
208206
if _power_station.cpu:
209207
logger.debug("Applying CPU performance settings from profile")
@@ -299,3 +297,18 @@ func _on_app_switched(_from: RunningApp, to: RunningApp) -> void:
299297
current_profile = profile
300298
profile_loaded.emit(profile)
301299
apply_profile(profile)
300+
301+
302+
# Get the currently available power profiles
303+
func get_power_profiles_available() -> PackedStringArray:
304+
# Detect all GPU cards
305+
var cards: Array[GpuCard] = []
306+
if _power_station.gpu:
307+
cards = _power_station.gpu.get_cards()
308+
309+
for card in cards:
310+
if card.class != "integrated":
311+
continue
312+
313+
return card.power_profiles_available
314+
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

core/ui/card_ui_overlay_mode/card_ui_overlay_mode.gd

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,27 @@ var underlay_window_id: int
3838
@onready var quick_bar_menu := $%QuickBarMenu
3939
@onready var settings_menu := $%SettingsMenu
4040

41+
# Constants
42+
43+
const remove_list: PackedStringArray = [
44+
"KeyboardButton",
45+
"NotifyButton",
46+
"HelpButton",
47+
"VolumeSlider",
48+
"BrightnessSlider",
49+
"PerGameToggle",
50+
"MangoAppSlider",
51+
"FramerateLimitSlider",
52+
"RefreshRateSlider"
53+
]
54+
55+
const settings_remove_list: PackedStringArray = [
56+
"LibraryButton",
57+
"NetworkButton",
58+
"BluetoothButton",
59+
"AudioButton"
60+
]
61+
4162
# Logger
4263
var logger := Log.get_logger("Main", Log.LEVEL.INFO)
4364

@@ -164,9 +185,8 @@ func _setup_overlay_mode(args: PackedStringArray) -> void:
164185
_start_underlay_process(args, log_path)
165186

166187
# Remove unneeded/conflicting elements from default menues
167-
var remove_list: PackedStringArray = ["PerformanceCard", "KeyboardButton", "NotifyButton", "HelpButton", "VolumeSlider", "BrightnessSlider", "PerGameToggle"]
188+
168189
_remove_children(remove_list, quick_bar_menu)
169-
var settings_remove_list: PackedStringArray = ["LibraryButton", "NetworkButton", "BluetoothButton", "AudioButton"]
170190
_remove_children(settings_remove_list, settings_menu)
171191

172192
# Setup inputplumber to receive guide presses.

0 commit comments

Comments
 (0)