Commit graph

97 commits

Author SHA1 Message Date
Josh Triplett
3369d31472 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>
2025-08-26 13:29:52 +08:00
Kate Hsuan
4d6da1bb0f tools: up-tool: rework upower dump and enumerate
1. Move dump and enumerate to the separated functions.
2. Introduce an output filter.

Co-work-with: Cursor
Reviewed-by: Kate Hsuan <hpa@redhat.com>
2025-08-20 14:25:37 +08:00
Ula Shipman
2724566a2a tools: Reorder upower(1) command-line options to match manual page 2025-06-04 10:45:49 -07:00
Ula Shipman
ec6631a11e tools: Handle invalid command-line arguments 2025-05-29 13:53:09 +08:00
Jelle van der Waa
17c14cc63f Revert "all: Remove Lid handling"
This reverts commit 07565ef6a1.

In the current systemd stable release 255 org.freedesktop.login1 does
not emit a LidisClosed event, this has added in systemd `main` and will
be availble in the next release.

As GNOME control panel still uses UPower's `LidIsclosed` property and
many other DE's such as Xfce/LXQt/Deepin as well revert this until the
systemd changes are available in all Distributions.

https://github.com/systemd/systemd/pull/30706

Resolve: https://gitlab.freedesktop.org/upower/upower/-/issues/260
2024-01-26 14:57:27 +00:00
Jelle van der Waa
18d550a555 Revert "lib: Remove deprecated up_client_get_devices()"
This reverts commit 6766602954.

Removing this and renaming up_client_get_devices2 to
up_client_get_devices means consumers have to support three cases to
support older UPower versions. So for example GNOME Control center now
uses up_client_get_devices2 and would have to now check if UPower
version > 0.92.
2024-01-26 10:20:50 +01:00
Bastien Nocera
6766602954 lib: Remove deprecated up_client_get_devices()
And rename up_client_get_devices2() to up_client_get_devices().
2023-07-06 11:15:02 +02:00
Bastien Nocera
07565ef6a1 all: Remove Lid handling
It is now handled solely in logind to take power management decisions,
and in the compositor for making decisions related to available
displays.

See:
https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html
2023-07-06 11:09:42 +02:00
Benjamin Berg
9058d45685 Remove Wakeups API
The API relied on /proc/timer_stats which has been removed from the
kernel in 2017. Since then, the API has been non-functional (yet
incorrectly reporting support because the support test was buggy).

Just remove it completely. The debian codesearch does not uncover any
API users. Also, I doubt that any new API (based on tracing scheduler
events as perf would do) would map well to what exists now. i.e. if
something like this is re-implemented in UPower or elsewhere, then the
API should likely look different.

And, realistically, if this does need root privileges (i.e. can't be
moved to use BPF programs or so on user units), then we can also create
a new small daemon that is launched on-demand just for that.
2022-03-24 17:02:27 +01:00
Bastien Nocera
0fd6b11085 all: Remove HAVE_CONFIG_H conditional
We always have a config.h now, and don't rely on autotools setting this
cflags for us to know it.
2021-09-07 17:20:48 +02:00
Bastien Nocera
9b93b6c402 build: Remove autotools 2021-09-06 14:06:40 +02:00
Bastien Nocera
6b9134c5d4 build: Clean up include_directories usage 2021-09-06 14:06:40 +02:00
Bastien Nocera
c0402747fd tools: Include top-level library include
So we don't need to define UP_COMPILATION
2021-09-02 17:47:30 +02:00
Benjamin Berg
f2e702d4dc build: Support building upower with meson 2021-09-02 17:47:30 +02:00
Benjamin Berg
706dcd44e4 up-tool: Catch NULL return for more upower API calls
This can lead to crashes if the communication with the daemon fails.

See https://bugzilla.redhat.com/show_bug.cgi?id=1922777
2021-02-04 09:45:50 +00:00
Robert Ancell
cb1071b9ab lib: Add a new version of up_client_get_devices which unrefs contents
The existing function didn't set the free function on the GPtrArray.
This means a libupower user can easily make a mistake in the reference
counting of the array contents.
2018-05-31 09:42:56 +12:00
Martin Pitt
4e83fabac1 up-tool: Exit early when connecting to upower fails
This avoids spewing dozens of assertions like

   libupower-glib-CRITICAL **: up_client_get_devices: assertion 'UP_IS_CLIENT (client)' failed
   libupower-glib-CRITICAL **: up_device_get_object_path: assertion 'UP_IS_DEVICE (device)' failed

and useless default values and then exiting successfully (which might confuse
users or scripts trying to parse the output).

Use the new up_client_new_full() constructor so that we get a proper GError.

Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350
2016-05-18 14:58:53 +02:00
Arnaud Quette
7371415beb Fix build regression
The removal of dbus-glib and libdbus build dependencies has introduced
a build regression on upower, which fails to link with gobject

Signed-off-by: Richard Hughes <richard@hughsie.com>
2015-08-10 11:06:30 +01:00
Cosimo Cecchi
b549d8928b build: remove dependency on dbus-glib and libdbus
Nothing depends on it any more.
2015-07-29 13:37:11 +01:00
Cosimo Cecchi
a037cffdee up-tool: remove unused variables 2015-07-29 13:37:11 +01:00
Bastien Nocera
5ed25a7e5f all: Remove IsDocked property
Removes the deprecated (for not very long) property, before we do a 1.0
release.

https://bugs.freedesktop.org/show_bug.cgi?id=78380
2014-05-07 11:01:27 +02:00
Bastien Nocera
e8beb269df tools: Remove is-docked from up-tool 2014-05-07 09:48:44 +02:00
Bastien Nocera
c91abb77ed tools: Update for lib API changes 2013-10-17 14:39:16 +02:00
Bastien Nocera
8453da5014 tools: Use notify signals instead of *changed ones 2013-10-17 12:40:05 +02:00
Bastien Nocera
db31456921 all: Add GetCriticalAction daemon method
This allows desktop front-ends to get which action will
actually be taken when we hit critical battery.

This is not a property as availability of actions might
change over the course of the run of the system, and
we didn't want to make unnecessary D-Bus calls on startup.
2013-10-17 09:04:03 +02:00
Bastien Nocera
b2f72dd69a all: Remove WarningLevel from the daemon properties
The WarningLevel property just replicated the warning level
on the display device, or at least should have. So we fix the latter
to remove the former.
2013-10-17 00:57:27 +02:00
Bastien Nocera
c00eda8ca0 tools: Print the display device when using -d 2013-10-17 00:46:01 +02:00
Bastien Nocera
0da46209f3 tools: Update for API changes 2013-10-14 10:42:56 +02:00
Bastien Nocera
bd7af247f0 tools: Remove use of deprecated features 2013-10-14 10:42:55 +02:00
Shih-Yuan Lee (FourDollars)
fdc62ad245 Set locale in daemon and tool
This is necessary to properly show non-UTF8 strings in debug mode (for the
daemon) and upower --dump etc. (for the tool).
2013-09-04 07:19:24 +02:00
Martin Pitt
7933b0e552 trivial: Stop calling deprecated g_type_init()
When building with a recent enough glib (>= 2.36), don't call g_type_init() any
more. This is deprecated and causes ugly compile warnings.
2013-08-29 11:10:15 +02:00
Richard Hughes
efa97d515f Use PIE to better secure installed tools and also use full RELRO in the daemon 2013-05-07 14:07:31 +01:00
Richard Hughes
372c2f8d29 Add a --enable-deprecated configure argument
This is turned off by default. If this is not set, then any calls to Suspend(),
SuspendAllowed(), Hibernate() or HibernateAllowed() will fail with an error.
The error mesage tells the user what new method to port to in logind.

I'm expecting to set --enable-deprecated for Fedora 17 and 18, but turn it off
for Fedora 19, so other distributions probably want to follow suit to find out
what other stuff needs to be ported to the new APIs early. GNOME should already
be fine, but KDE will need some solid porting as I understand it.

See http://lists.freedesktop.org/archives/devkit-devel/2013-January/001339.html
for more information on future plans and for rationale.
2013-02-12 11:08:35 +00:00
Richard Hughes
5be743c910 Don't use the deprecated INCLUDES in Makefile.am 2013-01-14 09:21:30 +00:00
Martin Pitt
99768c18eb Fix "can-hibernate" formatting in upower --dump
All other field names end with a colon, so that one should, too.
2012-11-08 09:53:49 +01:00
Richard Hughes
b19fca9637 Use git.mk and remove the manual .gitignore files 2011-07-19 12:40:21 +01:00
Landry Breuil
2527d0170d upower needs -pthread
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:38:48 +00:00
Michael Biebl
11301ae3d6 Drop devkit and devkit-power-daemon symlinks
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-02-23 16:18:53 +00:00
Richard Hughes
17b7aef701 linux: use the number of active DRM devices to determine the system docked status
Not ideal, but better than relying on ACPI.
2011-01-04 18:05:09 +00:00
Richard Hughes
59893663fb Port from EggDebug to the GLib built-in logging framework 2010-11-01 11:28:31 +00:00
Richard Hughes
bcc0c2ced0 Ensure we enumerate devices before we start monitoring them 2010-03-26 11:29:38 +00:00
Michael Biebl
3ea96602e6 Update help and g_option_context_new to upower 2010-02-06 13:42:57 +00:00
Richard Hughes
41917bfc73 trivial: fix a compile warning 2010-02-05 10:37:32 +00:00
Richard Hughes
29d4de79e1 Use GCancellable in libupower-glib so we can eventually get to GIO async methods without breaking future API 2010-02-05 09:41:06 +00:00
Richard Hughes
4c02c6310d Make the upower client tool use libupwer-glib, rather than devit-power-gobject 2010-02-05 09:26:10 +00:00
Michael Biebl
83c0574466 Remove EGG_* log define.
The EGG_* log defines don't seem to be used and still reference the old
DeviceKit-power name. So just remove it.
2010-02-05 08:35:11 +00:00
Richard Hughes
faeb7ffabc Rename the man pages and rename the main daemon binary name 2010-01-21 14:47:21 +00:00
Richard Hughes
adcb737767 Make the client tool be called upower, but maintain a symlink to devkit-power 2010-01-21 14:30:28 +00:00
Richard Hughes
d27c836e97 Rename the DBus service from org.freedesktop.DeviceKit.Power to org.freedesktop.UPower 2010-01-18 16:53:12 +00:00
Richard Hughes
8362088d12 trivial: rename some internal defines for the upower move 2010-01-18 14:04:24 +00:00