diff --git a/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so b/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so index 3007a58b..6fdb82d7 100755 Binary files a/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so and b/addons/dbus/bin/libdbus.linux.template_debug.x86_64.so differ diff --git a/addons/dbus/bin/libdbus.linux.template_release.x86_64.so b/addons/dbus/bin/libdbus.linux.template_release.x86_64.so index 9da5568d..eb363b43 100755 Binary files a/addons/dbus/bin/libdbus.linux.template_release.x86_64.so and b/addons/dbus/bin/libdbus.linux.template_release.x86_64.so differ diff --git a/core/systems/performance/performance_manager.gd b/core/systems/performance/performance_manager.gd index a81f0272..4cac964f 100644 --- a/core/systems/performance/performance_manager.gd +++ b/core/systems/performance/performance_manager.gd @@ -46,9 +46,14 @@ func _init() -> void: var battery := batteries[0] battery.updated.connect(_on_battery_updated.bind(battery)) + # Do nothing if PowerStation is not detected + if not _power_station.supports_power_station(): + return + # Load and apply the default profile var profile_state := get_profile_state() var path := get_profile_filename(profile_state) + path = "/".join([USER_PROFILES, path]) current_profile = load_or_create_profile(path) apply_profile(current_profile) @@ -141,18 +146,25 @@ func load_profile(profile_path: String) -> PerformanceProfile: ## Loads a PerformanceProfile from the given path. If the profile does not exist, ## it will create a new profile using the currently applied performance settings. func load_or_create_profile(profile_path: String, library_item: LibraryLaunchItem = null) -> PerformanceProfile: + logger.debug("Loading or creating profile: " + profile_path) # Try to load the profile if it exists var profile := load_profile(profile_path) if profile: + logger.debug("Found profile at: " + profile_path) return profile # If the profile does not exist, create one with the currently applied # performance settings. + logger.debug("No profile found. Creating one.") return create_profile(library_item) ## Applies the given performance profile to the system func apply_profile(profile: PerformanceProfile) -> void: + if not _power_station.supports_power_station(): + logger.info("Unable to apply performance profile. PowerStation not detected.") + return + logger.info("Applying performance profile: " + profile.name) # Apply CPU settings from the given profile @@ -272,6 +284,7 @@ func _on_app_switched(_from: RunningApp, to: RunningApp) -> void: # Load the performance profile based on the running game var profile_path := get_profile_filename(profile_state, to.launch_item) + profile_path = "/".join([USER_PROFILES, profile_path]) var profile := load_or_create_profile(profile_path, to.launch_item) current_profile = profile profile_loaded.emit(profile) diff --git a/core/systems/performance/power_station.gd b/core/systems/performance/power_station.gd index 0c1249bc..63cdea79 100644 --- a/core/systems/performance/power_station.gd +++ b/core/systems/performance/power_station.gd @@ -43,6 +43,8 @@ class CPUBus extends Resource: ## Returns a list of DBus object paths to every detected core func enumerate_cores() -> PackedStringArray: var result := _proxy.call_method(IFACE_CPU, "EnumerateCores") + if not result: + return [] var args := result.get_args() if args.size() != 1: return [] @@ -53,6 +55,8 @@ class CPUBus extends Resource: ## Returns true if the CPU has the given feature func has_feature(feature: String) -> bool: var result := _proxy.call_method(IFACE_CPU, "HasFeature", [feature], "s") + if not result: + return false var args := result.get_args() if args.size() != 1: return false @@ -118,6 +122,8 @@ class GPUBus extends Resource: ## Returns a list of DBus object paths to every detected GPU card func enumerate_cards() -> PackedStringArray: var result := _proxy.call_method(IFACE_GPU, "EnumerateCards") + if not result: + return [] var args := result.get_args() if args.size() != 1: return [] @@ -157,6 +163,8 @@ class GPUCard extends Resource: ## Returns a list of DBus object paths to every detected GPU connector func enumerate_connectors() -> PackedStringArray: var result := _proxy.call_method(IFACE_GPU_CARD, "EnumerateConnectors") + if not result: + return [] var args := result.get_args() if args.size() != 1: return [] diff --git a/core/ui/common/quick_bar/powertools_menu.gd b/core/ui/common/quick_bar/powertools_menu.gd index 733a68c5..3a050188 100644 --- a/core/ui/common/quick_bar/powertools_menu.gd +++ b/core/ui/common/quick_bar/powertools_menu.gd @@ -25,7 +25,7 @@ var power_station := load("res://core/systems/performance/power_station.tres") a var power_station_running := false var profile_loading := false var current_profile: PerformanceProfile -var logger := Log.get_logger("PowerTools", Log.LEVEL.INFO) +var logger := Log.get_logger("PowerTools", Log.LEVEL.DEBUG) # Called when the node enters the scene tree for the first time. @@ -85,6 +85,9 @@ func _ready() -> void: power_profile_dropdown.clear() power_profile_dropdown.add_item("Max Performance", 0) power_profile_dropdown.add_item("Power Saving", 1) + + # Set the initial values + _on_profile_loaded(performance_manager.current_profile) # Triggers when the apply timer times out. The apply timer will start/restart @@ -95,6 +98,19 @@ func _on_apply_timer_timeout() -> void: logger.debug("No loaded profile to apply") return logger.debug("Applying and saving profile") + + # Update the profile based on the currently set values + current_profile.cpu_boost_enabled = cpu_boost_button.button_pressed + current_profile.cpu_smt_enabled = smt_button.button_pressed + print(smt_button.button_pressed) + current_profile.cpu_core_count_current = cpu_cores_slider.value + current_profile.tdp_current = tdp_slider.value + current_profile.tdp_boost_current = tdp_boost_slider.value + current_profile.gpu_manual_enabled = gpu_freq_enable.button_pressed + current_profile.gpu_freq_min_current = gpu_freq_min_slider.value + current_profile.gpu_freq_max_current = gpu_freq_max_slider.value + current_profile.gpu_temp_current = gpu_temp_slider.value + performance_manager.apply_and_save_profile(current_profile) @@ -111,6 +127,11 @@ func _on_service_timer_timeout() -> void: ## Called when a performance profile is loaded func _on_profile_loaded(profile: PerformanceProfile) -> void: + if not power_station.supports_power_station(): + logger.info("Unable to load performance profile. PowerStation not detected.") + return + + logger.debug("Updating UI with loaded performance profile") # Keep track of the currently loaded profile current_profile = profile @@ -154,6 +175,7 @@ func _setup_interface() -> void: cpu_boost_button.visible = cpu.has_feature("cpb") smt_button.visible = cpu.has_feature("ht") cpu_cores_slider.max_value = cpu.cores_count + cpu_cores_slider.visible = true # Configure GPU components if power_station.gpu: diff --git a/core/ui/common/quick_bar/powertools_menu.tscn b/core/ui/common/quick_bar/powertools_menu.tscn index b0ca9bf6..0d0b8e78 100644 --- a/core/ui/common/quick_bar/powertools_menu.tscn +++ b/core/ui/common/quick_bar/powertools_menu.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=8 format=3 uid="uid://dv3dt0j3jketh"] +[gd_scene load_steps=9 format=3 uid="uid://dv3dt0j3jketh"] [ext_resource type="Script" path="res://core/ui/common/quick_bar/powertools_menu.gd" id="1_qncpn"] [ext_resource type="PackedScene" uid="uid://8m20p2s0v5gb" path="res://core/systems/input/focus_group.tscn" id="2_h0jgv"] [ext_resource type="Resource" uid="uid://dpc1o781f43ef" path="res://core/ui/card_ui/quick_bar/quick_bar_menu_focus.tres" id="3_0iyf7"] [ext_resource type="PackedScene" uid="uid://dithv38oqgy58" path="res://core/ui/components/section_label.tscn" id="4_1pfjc"] [ext_resource type="PackedScene" uid="uid://d1qb7euwlu7bh" path="res://core/ui/components/toggle.tscn" id="5_xig3u"] +[ext_resource type="PackedScene" uid="uid://d0u3rsa5qpj57" path="res://core/ui/components/subsection_label.tscn" id="5_yr563"] [ext_resource type="PackedScene" uid="uid://cemxrvvjgm4g" path="res://core/ui/components/slider.tscn" id="6_7aip6"] [ext_resource type="PackedScene" uid="uid://xei5afwefxud" path="res://core/ui/components/dropdown.tscn" id="7_0kvsa"] @@ -16,23 +17,23 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_qncpn") -[node name="FocusGroup" parent="." node_paths=PackedStringArray("current_focus") instance=ExtResource("2_h0jgv")] -current_focus = NodePath("../CPUBoostButton") +[node name="FocusGroup" parent="." instance=ExtResource("2_h0jgv")] focus_stack = ExtResource("3_0iyf7") [node name="ApplyTimer" type="Timer" parent="."] wait_time = 1.5 one_shot = true -autostart = true [node name="ServiceTimer" type="Timer" parent="."] wait_time = 5.0 autostart = true -[node name="WaitLabel" parent="." instance=ExtResource("4_1pfjc")] +[node name="WaitLabel" parent="." instance=ExtResource("5_yr563")] layout_mode = 2 text = "Waiting for PowerStation service..." horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 3 [node name="CPUSectionLabel" parent="." instance=ExtResource("4_1pfjc")] visible = false @@ -50,7 +51,6 @@ focus_next = NodePath("../SMTButton") focus_previous = NodePath("../GPUTempSlider") text = "CPU Boost" separator_visible = false -button_pressed = false [node name="SMTButton" parent="." instance=ExtResource("5_xig3u")] visible = false @@ -63,7 +63,6 @@ focus_next = NodePath("../CPUCoresSlider") focus_previous = NodePath("../CPUBoostButton") text = "SMT Enabled" separator_visible = false -button_pressed = false [node name="CPUCoresSlider" parent="." instance=ExtResource("6_7aip6")] visible = false @@ -116,7 +115,6 @@ focus_next = NodePath("../GPUFreqMinSlider") focus_previous = NodePath("../TDPBoostSlider") text = "Manual Freq" separator_visible = false -button_pressed = false [node name="GPUFreqMinSlider" parent="." instance=ExtResource("6_7aip6")] visible = false diff --git a/core/ui/components/toggle.gd b/core/ui/components/toggle.gd index 287c3076..c657e7d0 100644 --- a/core/ui/components/toggle.gd +++ b/core/ui/components/toggle.gd @@ -26,6 +26,10 @@ signal toggled(pressed: bool) @export_category("Toggle Settings") @export var button_pressed := false: + get: + if check_button: + return check_button.button_pressed + return button_pressed set(v): button_pressed = v if check_button: