diff options
-rw-r--r-- | docs/guide/libraries/tray.md | 2 | ||||
-rw-r--r-- | lang/lua/astal/binding.lua | 26 | ||||
-rw-r--r-- | lang/lua/astal/gtk3/app.lua | 47 | ||||
-rw-r--r-- | lang/lua/astal/gtk3/astalify.lua | 4 | ||||
-rw-r--r-- | lang/lua/astal/gtk3/widget.lua | 1 | ||||
-rw-r--r-- | lang/lua/astal/init.lua | 1 | ||||
-rw-r--r-- | lang/lua/astal/variable.lua | 25 | ||||
l---------[-rw-r--r--] | lib/astal/gtk4/gir.py | 59 | ||||
l---------[-rw-r--r--] | lib/astal/io/gir.py | 59 | ||||
-rw-r--r-- | lib/gir.py | 3 | ||||
-rw-r--r-- | lib/hyprland/monitor.vala | 24 | ||||
-rw-r--r-- | lib/powerprofiles/cli.vala | 49 | ||||
l--------- | lib/powerprofiles/gir.py | 1 | ||||
-rw-r--r-- | lib/powerprofiles/meson.build | 44 | ||||
-rw-r--r-- | lib/powerprofiles/power-profiles.vala | 109 |
15 files changed, 217 insertions, 237 deletions
diff --git a/docs/guide/libraries/tray.md b/docs/guide/libraries/tray.md index 39dffc1..43b3aa6 100644 --- a/docs/guide/libraries/tray.md +++ b/docs/guide/libraries/tray.md @@ -62,7 +62,7 @@ sudo pacman -Syu meson gtk3 gobject-introspection libdbusmenu-gtk3 ``` ```sh [<i class="devicon-fedora-plain"></i> Fedora] -sudo dnf install meson gcc gtk3-devel libdbusmenu-gtk3 gobject-introspection-devel +sudo dnf install meson gcc gtk3-devel libdbusmenu-gtk3-devel gobject-introspection-devel ``` ```sh [<i class="devicon-ubuntu-plain"></i> Ubuntu] diff --git a/lang/lua/astal/binding.lua b/lang/lua/astal/binding.lua index 2944ec4..dd2df7f 100644 --- a/lang/lua/astal/binding.lua +++ b/lang/lua/astal/binding.lua @@ -2,12 +2,14 @@ local lgi = require("lgi") local GObject = lgi.require("GObject", "2.0") ---@class Binding ----@field emitter table|Variable +---@field emitter table | Variable | userdata ---@field property? string ---@field transform_fn function +---@overload fun(emitter: table | userdata, property?: string): Binding local Binding = {} +Binding.__index = Binding ----@param emitter table +---@param emitter table | Variable | userdata ---@param property? string ---@return Binding function Binding.new(emitter, property) @@ -28,14 +30,15 @@ function Binding:__tostring() return str .. ">" end +---@return any function Binding:get() if self.property ~= nil and GObject.Object:is_type_of(self.emitter) then return self.transform_fn(self.emitter[self.property]) - end - if type(self.emitter.get) == "function" then + elseif type(self.emitter.get) == "function" then return self.transform_fn(self.emitter:get()) + else + error("can not get: Not a GObject or a Variable " + self) end - error("can not get: Not a GObject or a Variable " + self) end ---@param transform fun(value: any): any @@ -58,14 +61,17 @@ function Binding:subscribe(callback) return function() GObject.signal_handler_disconnect(self.emitter, id) end - end - if type(self.emitter.subscribe) == "function" then + elseif type(self.emitter.subscribe) == "function" then return self.emitter:subscribe(function() callback(self:get()) end) + else + error("can not subscribe: Not a GObject or a Variable " + self) end - error("can not subscribe: Not a GObject or a Variable " + self) end -Binding.__index = Binding -return Binding +return setmetatable(Binding, { + __call = function(_, emitter, prop) + return Binding.new(emitter, prop) + end, +}) diff --git a/lang/lua/astal/gtk3/app.lua b/lang/lua/astal/gtk3/app.lua index 7895f69..58564ce 100644 --- a/lang/lua/astal/gtk3/app.lua +++ b/lang/lua/astal/gtk3/app.lua @@ -25,29 +25,26 @@ end local app = AstalLua() ---@class StartConfig ----@field icons? string ----@field instance_name? string ----@field gtk_theme? string ----@field icon_theme? string ----@field cursor_theme? string ----@field css? string ----@field hold? boolean ----@field request_handler? fun(msg: string, response: fun(res: any)) ----@field main? fun(...): unknown ----@field client? fun(message: fun(msg: string): string, ...): unknown +---@field icons string? +---@field instance_name string? +---@field gtk_theme string? +---@field icon_theme string? +---@field cursor_theme string? +---@field css string? +---@field hold boolean? +---@field request_handler fun(msg: string, response: fun(res: any)): nil +---@field main fun(...): nil +---@field client fun(message: fun(msg: string): string, ...): nil ----@param config StartConfig | nil +---@param config? StartConfig function Astal.Application:start(config) - if config == nil then - config = {} - end + config = config or {} - if config.client == nil then - config.client = function() + config.client = config.client + or function() print('Astal instance "' .. app.instance_name .. '" is already running') os.exit(1) end - end if config.hold == nil then config.hold = true @@ -61,17 +58,11 @@ function Astal.Application:start(config) if config.icons then self:add_icons(config.icons) end - if config.instance_name then - self.instance_name = config.instance_name - end - if config.gtk_theme then - self.gtk_theme = config.gtk_theme - end - if config.icon_theme then - self.icon_theme = config.icon_theme - end - if config.cursor_theme then - self.cursor_theme = config.cursor_theme + + for _, key in ipairs({ "instance_name", "gtk_theme", "icon_theme", "cursor_theme" }) do + if config[key] then + self[key] = config[key] + end end app.on_activate = function() diff --git a/lang/lua/astal/gtk3/astalify.lua b/lang/lua/astal/gtk3/astalify.lua index 211a1d4..95faa2c 100644 --- a/lang/lua/astal/gtk3/astalify.lua +++ b/lang/lua/astal/gtk3/astalify.lua @@ -163,9 +163,7 @@ return function(ctor) end return function(tbl) - if tbl == nil then - tbl = {} - end + tbl = tbl or {} local bindings = {} local setup = tbl.setup diff --git a/lang/lua/astal/gtk3/widget.lua b/lang/lua/astal/gtk3/widget.lua index beaad6c..c8857e7 100644 --- a/lang/lua/astal/gtk3/widget.lua +++ b/lang/lua/astal/gtk3/widget.lua @@ -3,6 +3,7 @@ local Astal = lgi.require("Astal", "3.0") local Gtk = lgi.require("Gtk", "3.0") local astalify = require("astal.gtk3.astalify") +---@overload fun(ctor: any): function local Widget = { astalify = astalify, Box = astalify(Astal.Box), diff --git a/lang/lua/astal/init.lua b/lang/lua/astal/init.lua index 5630ba4..190994a 100644 --- a/lang/lua/astal/init.lua +++ b/lang/lua/astal/init.lua @@ -7,6 +7,7 @@ local Binding = require("astal.binding") local File = require("astal.file") local Process = require("astal.process") local Time = require("astal.time") +---@type Variable | fun(v: any): Variable local Variable = require("astal.variable") return { diff --git a/lang/lua/astal/variable.lua b/lang/lua/astal/variable.lua index 2305a71..ad59a3f 100644 --- a/lang/lua/astal/variable.lua +++ b/lang/lua/astal/variable.lua @@ -17,6 +17,7 @@ local Process = require("astal.process") ---@field private poll_fn? function ---@field private watch_transform? fun(next: any, prev: any): any ---@field private watch_exec? string[] | string +---@overload fun(transform?: fun(v: any): any): Binding local Variable = {} Variable.__index = Variable @@ -24,23 +25,23 @@ Variable.__index = Variable ---@return Variable function Variable.new(value) local v = Astal.VariableBase() - local variable = setmetatable({ - variable = v, - _value = value, - }, Variable) + local variable = setmetatable({ variable = v, _value = value }, Variable) + v.on_dropped = function() variable:stop_watch() variable:stop_poll() end + v.on_error = function(_, err) if variable.err_handler then variable.err_handler(err) end end + return variable end ----@param transform? fun(v: any): any +---@param transform? fun(v: any): any ---@return Binding function Variable:__call(transform) if type(transform) == "nil" then @@ -54,10 +55,13 @@ function Variable:__tostring() return "Variable<" .. tostring(self:get()) .. ">" end +---@return any function Variable:get() return self._value end +---@param value any +---@return nil function Variable:set(value) if value ~= self:get() then self._value = value @@ -107,7 +111,6 @@ function Variable:start_watch() end) end - function Variable:stop_poll() if self:is_polling() then self._poll.cancel() @@ -122,7 +125,6 @@ function Variable:stop_watch() self._watch = nil end - function Variable:drop() self.variable.emit_dropped() end @@ -180,8 +182,9 @@ end ---@param exec string | string[] ---@param transform? fun(next: any, prev: any): any +---@return Variable function Variable:watch(exec, transform) - transform = transform or function (next) + transform = transform or function(next) return next end @@ -240,7 +243,7 @@ function Variable.derive(deps, transform) for i, var in ipairs(deps) do if getmetatable(var) == Variable then - deps[i] = Binding.new(var) + deps[i] = var() end end @@ -249,7 +252,7 @@ function Variable.derive(deps, transform) for i, binding in ipairs(deps) do params[i] = binding:get() end - return transform(table.unpack(params), 1, #deps) + return transform(table.unpack(params, 1, #deps)) end local var = Variable.new(update()) @@ -272,4 +275,4 @@ return setmetatable(Variable, { __call = function(_, v) return Variable.new(v) end, -})
\ No newline at end of file +}) diff --git a/lib/astal/gtk4/gir.py b/lib/astal/gtk4/gir.py index 9ef680f..16a3a64 100644..120000 --- a/lib/astal/gtk4/gir.py +++ b/lib/astal/gtk4/gir.py @@ -1,58 +1 @@ -""" -Vala's generated gir does not contain comments, -so we use valadoc to generate them. However, they are formatted -for valadoc and not gi-docgen so we need to fix it. -""" - -import xml.etree.ElementTree as ET -import html -import sys -import subprocess - - -def fix_gir(name: str, gir: str, out: str): - namespaces = { - "": "http://www.gtk.org/introspection/core/1.0", - "c": "http://www.gtk.org/introspection/c/1.0", - "glib": "http://www.gtk.org/introspection/glib/1.0", - } - for prefix, uri in namespaces.items(): - ET.register_namespace(prefix, uri) - - tree = ET.parse(gir) - root = tree.getroot() - - for doc in root.findall(".//doc", namespaces): - if doc.text: - doc.text = ( - html.unescape(doc.text).replace("<para>", "").replace("</para>", "") - ) - - if (inc := root.find("c:include", namespaces)) is not None: - inc.set("name", f"{name}.h") - else: - print("no c:include tag found", file=sys.stderr) - exit(1) - - tree.write(out, encoding="utf-8", xml_declaration=True) - - -def valadoc(name: str, gir: str, args: list[str]): - cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args] - try: - subprocess.run(cmd, check=True, text=True, capture_output=True) - except subprocess.CalledProcessError as e: - print(e.stderr, file=sys.stderr) - exit(1) - - -if __name__ == "__main__": - name = sys.argv[1] - in_out = sys.argv[2].split(":") - args = sys.argv[3:] - - gir = in_out[0] - out = in_out[1] if len(in_out) > 1 else gir - - valadoc(name, gir, args) - fix_gir(name, gir, out) +../../gir.py
\ No newline at end of file diff --git a/lib/astal/io/gir.py b/lib/astal/io/gir.py index 9ef680f..16a3a64 100644..120000 --- a/lib/astal/io/gir.py +++ b/lib/astal/io/gir.py @@ -1,58 +1 @@ -""" -Vala's generated gir does not contain comments, -so we use valadoc to generate them. However, they are formatted -for valadoc and not gi-docgen so we need to fix it. -""" - -import xml.etree.ElementTree as ET -import html -import sys -import subprocess - - -def fix_gir(name: str, gir: str, out: str): - namespaces = { - "": "http://www.gtk.org/introspection/core/1.0", - "c": "http://www.gtk.org/introspection/c/1.0", - "glib": "http://www.gtk.org/introspection/glib/1.0", - } - for prefix, uri in namespaces.items(): - ET.register_namespace(prefix, uri) - - tree = ET.parse(gir) - root = tree.getroot() - - for doc in root.findall(".//doc", namespaces): - if doc.text: - doc.text = ( - html.unescape(doc.text).replace("<para>", "").replace("</para>", "") - ) - - if (inc := root.find("c:include", namespaces)) is not None: - inc.set("name", f"{name}.h") - else: - print("no c:include tag found", file=sys.stderr) - exit(1) - - tree.write(out, encoding="utf-8", xml_declaration=True) - - -def valadoc(name: str, gir: str, args: list[str]): - cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args] - try: - subprocess.run(cmd, check=True, text=True, capture_output=True) - except subprocess.CalledProcessError as e: - print(e.stderr, file=sys.stderr) - exit(1) - - -if __name__ == "__main__": - name = sys.argv[1] - in_out = sys.argv[2].split(":") - args = sys.argv[3:] - - gir = in_out[0] - out = in_out[1] if len(in_out) > 1 else gir - - valadoc(name, gir, args) - fix_gir(name, gir, out) +../../gir.py
\ No newline at end of file @@ -9,6 +9,7 @@ import html import sys import subprocess import re +import os # valac fails on gi-docgen compliant markdown @@ -47,7 +48,7 @@ def fix_gir(name: str, gir: str, out: str): def valadoc(name: str, gir: str, args: list[str]): - cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args] + cmd = [os.getenv("VALADOC", "valadoc"), "-o", "docs", "--package-name", name, "--gir", gir, *args] try: subprocess.run(cmd, check=True, text=True, capture_output=True) except subprocess.CalledProcessError as e: diff --git a/lib/hyprland/monitor.vala b/lib/hyprland/monitor.vala index d7b8028..6c46142 100644 --- a/lib/hyprland/monitor.vala +++ b/lib/hyprland/monitor.vala @@ -1,5 +1,4 @@ -namespace AstalHyprland { -public class Monitor : Object { +public class AstalHyprland.Monitor : Object { public signal void removed (); public int id { get; private set; } @@ -20,6 +19,7 @@ public class Monitor : Object { public int reserved_left { get; private set; } public int reserved_right { get; private set; } public double scale { get; private set; } + public Transform transform { get; private set; } public bool focused { get; private set; } public bool dpms_status { get; private set; } public bool vrr { get; private set; } @@ -43,6 +43,7 @@ public class Monitor : Object { x = (int)obj.get_int_member("x"); y = (int)obj.get_int_member("y"); scale = obj.get_double_member("scale"); + transform = (Transform)obj.get_int_member("transform"); focused = obj.get_boolean_member("focused"); dpms_status = obj.get_boolean_member("dpmsStatus"); vrr = obj.get_boolean_member("vrr"); @@ -67,5 +68,22 @@ public class Monitor : Object { public void focus() { Hyprland.get_default().dispatch("focusmonitor", id.to_string()); } -} + + public enum Transform { + NORMAL = 0, + /** rotate by 90° counter clockwise */ + ROTATE_90_DEG = 1, + /** rotate by 180° */ + ROTATE_180_DEG = 2, + /** rotate by 270° counter clockwise */ + ROTATE_270_DEG = 3, + /** mirror both axis */ + FLIPPED = 4, + /** flip and rotate by 90° */ + FLIPPED_ROTATE_90_DEG = 5, + /** flip and rotate by 180° */ + FLIPPED_ROTATE_180_DEG = 6, + /** flip and rotate by 270° */ + FLIPPED_ROTATE_270_DEG = 7, + } } diff --git a/lib/powerprofiles/cli.vala b/lib/powerprofiles/cli.vala index 7be01d2..1e5cc70 100644 --- a/lib/powerprofiles/cli.vala +++ b/lib/powerprofiles/cli.vala @@ -56,16 +56,16 @@ int main(string[] argv) { if (daemonize) { var loop = new MainLoop(); - stdout.printf("%s\n", profiles.to_json_string()); + stdout.printf("%s\n", to_json_string(profiles)); stdout.flush(); profiles.notify.connect(() => { - stdout.printf("%s\n", profiles.to_json_string()); + stdout.printf("%s\n", to_json_string(profiles)); stdout.flush(); }); profiles.profile_released.connect(() => { - stdout.printf("%s\n", profiles.to_json_string()); + stdout.printf("%s\n", to_json_string(profiles)); stdout.flush(); }); @@ -73,8 +73,49 @@ int main(string[] argv) { } if (set == null && !daemonize) { - stdout.printf("%s\n", profiles.to_json_string()); + stdout.printf("%s\n", to_json_string(profiles)); } return 0; } + +string to_json_string(AstalPowerProfiles.PowerProfiles profiles) { + var acts = new Json.Builder().begin_array(); + foreach (var action in profiles.actions) { + acts.add_string_value(action); + } + + var active_holds = new Json.Builder().begin_array(); + foreach (var action in profiles.active_profile_holds) { + active_holds.add_value(new Json.Builder() + .begin_object() + .set_member_name("application_id").add_string_value(action.application_id) + .set_member_name("profile").add_string_value(action.profile) + .set_member_name("reason").add_string_value(action.reason) + .end_object() + .get_root()); + } + + var profs = new Json.Builder().begin_array(); + 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("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) + .end_object() + .get_root()); + } + + return Json.to_string(new Json.Builder() + .begin_object() + .set_member_name("active_profile").add_string_value(profiles.active_profile) + .set_member_name("icon_name").add_string_value(profiles.icon_name) + .set_member_name("performance_degraded").add_string_value(profiles.performance_degraded) + .set_member_name("actions").add_value(acts.end_array().get_root()) + .set_member_name("active_profile_holds").add_value(active_holds.end_array().get_root()) + .set_member_name("profiles").add_value(profs.end_array().get_root()) + .end_object() + .get_root(), false); +} diff --git a/lib/powerprofiles/gir.py b/lib/powerprofiles/gir.py new file mode 120000 index 0000000..b5b4f1d --- /dev/null +++ b/lib/powerprofiles/gir.py @@ -0,0 +1 @@ +../gir.py
\ No newline at end of file diff --git a/lib/powerprofiles/meson.build b/lib/powerprofiles/meson.build index d0fe78f..cd8cc2b 100644 --- a/lib/powerprofiles/meson.build +++ b/lib/powerprofiles/meson.build @@ -39,32 +39,38 @@ deps = [ dependency('json-glib-1.0'), ] -sources = [ - config, +sources = [config] + files( 'power-profiles.vala', -] +) if get_option('lib') lib = library( meson.project_name(), sources, dependencies: deps, + vala_args: ['--vapi-comments'], vala_header: meson.project_name() + '.h', vala_vapi: meson.project_name() + '-' + api_version + '.vapi', - vala_gir: gir, version: meson.project_version(), install: true, - install_dir: [true, true, true, true], + install_dir: [true, true, true], ) - import('pkgconfig').generate( - lib, - name: meson.project_name(), - filebase: meson.project_name() + '-' + api_version, - version: meson.project_version(), - subdirs: meson.project_name(), - requires: deps, - install_dir: get_option('libdir') / 'pkgconfig', + pkgs = [] + foreach dep : deps + pkgs += ['--pkg=' + dep.name()] + endforeach + + gir_tgt = custom_target( + gir, + command: [find_program('python3'), files('gir.py'), meson.project_name(), gir] + + pkgs + + sources, + input: sources, + depends: lib, + output: gir, + install: true, + install_dir: get_option('datadir') / 'gir-1.0', ) custom_target( @@ -77,10 +83,20 @@ if get_option('lib') ], input: lib, output: typelib, - depends: lib, + depends: [lib, gir_tgt], install: true, install_dir: get_option('libdir') / 'girepository-1.0', ) + + import('pkgconfig').generate( + lib, + name: meson.project_name(), + filebase: meson.project_name() + '-' + api_version, + version: meson.project_version(), + subdirs: meson.project_name(), + requires: deps, + install_dir: get_option('libdir') / 'pkgconfig', + ) endif if get_option('cli') diff --git a/lib/powerprofiles/power-profiles.vala b/lib/powerprofiles/power-profiles.vala index ab98505..a104d2e 100644 --- a/lib/powerprofiles/power-profiles.vala +++ b/lib/powerprofiles/power-profiles.vala @@ -16,11 +16,17 @@ private interface IPowerProfiles : DBusProxy { } public PowerProfiles get_default() { + /** Gets the default singleton PowerProfiles instance. */ return PowerProfiles.get_default(); } +/** + * Client for [[https://freedesktop-team.pages.debian.net/power-profiles-daemon/gdbus-org.freedesktop.UPower.PowerProfiles.html|PowerProfiles]]. + */ public class PowerProfiles : Object { private static PowerProfiles instance; + + /** Gets the default singleton PowerProfiles instance. */ public static PowerProfiles get_default() { if (instance == null) instance = new PowerProfiles(); @@ -52,19 +58,34 @@ public class PowerProfiles : Object { } } + /** + * The type of the currently active profile. + * It might change automatically if a profile is held, + * using the [[email protected]_profile] method. + */ public string active_profile { owned get { return proxy.active_profile; } set { proxy.active_profile = value; } } + /** + * Return a named icon based [[email protected]:active_profile]. + */ public string icon_name { owned get { return @"power-profile-$active_profile-symbolic"; } } + /** + * List of the "actions" implemented in the running daemon. + * This can used to figure out whether particular functionality is available in the daemon. + */ public string[] actions { owned get { return proxy.actions.copy(); } } + /** + * List of dictionaries representing the current profile holds. + */ public Hold[] active_profile_holds { owned get { Hold[] holds = new Hold[proxy.active_profile_holds.length]; @@ -80,14 +101,21 @@ public class PowerProfiles : Object { } } + /** + * This will be set if the performance power profile is running in degraded mode, + * with the value being used to identify the reason for that degradation. + * Possible values are: + * - "lap-detected" (the computer is sitting on the user's lap) + * - "high-operating-temperature" (the computer is close to overheating) + * - "" (the empty string, if not performance is not degraded) + */ public string performance_degraded { owned get { return proxy.performance_degraded; } } - public string performance_inhibited { - owned get { return proxy.performance_degraded; } - } - + /** + * List of each profile. + */ public Profile[] profiles { owned get { Profile[] profs = new Profile[proxy.profiles.length]; @@ -104,12 +132,31 @@ public class PowerProfiles : Object { } } + /** + * The version of the power-profiles-daemon software. + */ public string version { owned get { return proxy.version; } } + /** + * Emitted when the profile is released because + * [[email protected]:active_profile] was manually changed. + * This will only be emitted to the process that originally called + * [[email protected]_profile]. + */ public signal void profile_released (uint cookie); + /** + * This forces the passed profile (either 'power-saver' or 'performance') + * to be activated until either the caller quits, + * [[email protected]_profile] is called, + * or the [[email protected]:active_profile] is changed by the user. + * When conflicting profiles are requested to be held, + * the 'power-saver' profile will be activated in preference to the 'performance' profile. + * Those holds will be automatically cancelled if the user manually switches to another profile, + * and the [[email protected]::profile_released] signal will be emitted. + */ public int hold_profile(string profile, string reason, string application_id) { try { return (int)proxy.hold_profile(profile, reason, application_id); @@ -119,6 +166,9 @@ public class PowerProfiles : Object { } } + /** + * This removes the hold that was set on a profile. + */ public void release_profile(uint cookie) { try { proxy.release_profile(cookie); @@ -126,54 +176,21 @@ public class PowerProfiles : Object { critical(error.message); } } - - public string to_json_string() { - var acts = new Json.Builder().begin_array(); - foreach (var action in actions) { - acts.add_string_value(action); - } - - var active_holds = new Json.Builder().begin_array(); - foreach (var action in active_profile_holds) { - active_holds.add_value(new Json.Builder() - .begin_object() - .set_member_name("application_id").add_string_value(action.application_id) - .set_member_name("profile").add_string_value(action.profile) - .set_member_name("reason").add_string_value(action.reason) - .end_object() - .get_root()); - } - - var profs = new Json.Builder().begin_array(); - foreach (var prof in profiles) { - profs.add_value(new Json.Builder() - .begin_object() - .set_member_name("profie").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) - .end_object() - .get_root()); - } - - return Json.to_string(new Json.Builder() - .begin_object() - .set_member_name("active_profile").add_string_value(active_profile) - .set_member_name("icon_name").add_string_value(icon_name) - .set_member_name("performance_degraded").add_string_value(performance_degraded) - .set_member_name("performance_inhibited").add_string_value(performance_inhibited) - .set_member_name("actions").add_value(acts.end_array().get_root()) - .set_member_name("active_profile_holds").add_value(active_holds.end_array().get_root()) - .set_member_name("profiles").add_value(profs.end_array().get_root()) - .end_object() - .get_root(), false); - } } public struct Profile { + /** + * Will be one of: + * - "power-saver" (battery saving profile) + * - "balanced" (the default profile) + * - "performance" (a profile that does not care about noise or battery consumption) + */ public string profile; public string cpu_driver; public string platform_driver; + /** + * Identifies the power-profiles-daemon backend code used to implement the profile. + */ public string driver; } |