mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 02:00:03 +01:00
upower: Add a -b/--battery option to dump only battery information
This is useful when asking people to give information about battery health. It avoids having to give two-step instructions of first enumerating devices with `upower -e`, then looking for a device whose name starts with `/org/freedesktop/UPower/devices/battery_`, then running `upower -i` on that device. Signed-off-by: Josh Triplett <josh@joshtriplett.org>
This commit is contained in:
parent
ff605e51c1
commit
3369d31472
3 changed files with 17 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ _enumerate_objects() {
|
|||
}
|
||||
|
||||
_arguments \
|
||||
"(--battery -b)"{--battery,-b}"[Dump all parameters for battery objects]" \
|
||||
"(--enumerate -e)"{--enumerate,-e}"[Enumerate objects paths for devices]" \
|
||||
"(--dump -d)"{--dump,-d}"[Dump all parameters for all objects]" \
|
||||
"(--monitor -m)"{--monitor,-m}"[Monitor activity from the power daemon]" \
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>upower</command>
|
||||
<arg><option>--battery</option></arg>
|
||||
<arg><option>--dump</option></arg>
|
||||
<arg><option>--enumerate</option></arg>
|
||||
<arg><option>--monitor-detail</option></arg>
|
||||
|
|
@ -42,6 +43,14 @@
|
|||
<refsect1>
|
||||
<title>OPTIONS</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-b</option>, <option>--battery</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Dump all parameters for battery devices.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-d</option>, <option>--dump</option></term>
|
||||
<listitem>
|
||||
|
|
|
|||
|
|
@ -272,6 +272,7 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean opt_battery = FALSE;
|
||||
gboolean opt_dump = FALSE;
|
||||
gboolean opt_enumerate = FALSE;
|
||||
gboolean opt_monitor = FALSE;
|
||||
|
|
@ -287,6 +288,7 @@ main (int argc, char **argv)
|
|||
UpDevice *device;
|
||||
|
||||
const GOptionEntry entries[] = {
|
||||
{ "battery", 'b', 0, G_OPTION_ARG_NONE, &opt_battery, _("Dump all parameters for battery objects"), NULL },
|
||||
{ "dump", 'd', 0, G_OPTION_ARG_NONE, &opt_dump, _("Dump all parameters for all objects"), NULL },
|
||||
{ "enumerate", 'e', 0, G_OPTION_ARG_NONE, &opt_enumerate, _("Enumerate objects paths for devices"), NULL },
|
||||
{ "monitor", 'm', 0, G_OPTION_ARG_NONE, &opt_monitor, _("Monitor activity from the power daemon"), NULL },
|
||||
|
|
@ -333,6 +335,11 @@ main (int argc, char **argv)
|
|||
if (opt_enumerate)
|
||||
return up_tool_output_enumerate (client);
|
||||
|
||||
if (opt_battery) {
|
||||
device_filter = g_list_append (device_filter, GINT_TO_POINTER (UP_DEVICE_KIND_BATTERY));
|
||||
opt_dump = TRUE;
|
||||
}
|
||||
|
||||
if (opt_dump) {
|
||||
retval = up_tool_output_device_dump (client, device_filter);
|
||||
g_list_free (device_filter);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue