Skip to content

Commit

Permalink
fix #179: power profiles missing profile key
Browse files Browse the repository at this point in the history
  • Loading branch information
Aylur committed Dec 13, 2024
1 parent d8d62d7 commit 4f47b69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/powerprofiles/cli.vala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ string to_json_string(AstalPowerProfiles.PowerProfiles profiles) {
foreach (var prof in profiles.profiles) {
profs.add_value(new Json.Builder()
.begin_object()
.set_member_name("profie").add_string_value(prof.profile)
.set_member_name("profile").add_string_value(prof.profile)
.set_member_name("driver").add_string_value(prof.driver)
.set_member_name("cpu_driver").add_string_value(prof.cpu_driver)
.set_member_name("platform_driver").add_string_value(prof.platform_driver)
Expand Down
13 changes: 9 additions & 4 deletions lib/powerprofiles/power-profiles.vala
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public class PowerProfiles : Object {
owned get { return proxy.performance_degraded; }
}

private string? get_hashtable_string(HashTable<string, Variant> table, string key) {
var v = table.get(key);
return v == null ? null : v.get_string();
}

/**
* List of each profile.
*/
Expand All @@ -122,10 +127,10 @@ public class PowerProfiles : Object {
for (var i = 0; i < proxy.profiles.length; ++i) {
var prof = proxy.profiles[i];
profs[i] = Profile() {
profile = prof.get("Profile").get_string(),
cpu_driver = prof.get("CpuDriver").get_string(),
platform_driver = prof.get("PlatformDriver").get_string(),
driver = prof.get("Driver").get_string()
profile = get_hashtable_string(prof, "Profile"),
cpu_driver = get_hashtable_string(prof, "CpuDriver"),
platform_driver = get_hashtable_string(prof, "PlatformDriver"),
driver = get_hashtable_string(prof, "Driver"),
};
}
return profs;
Expand Down

0 comments on commit 4f47b69

Please sign in to comment.