Commit graph

47 commits

Author SHA1 Message Date
Cosimo Cecchi
7258c4cce0 up-backend: remove unused private member 2015-07-29 13:37:11 +01:00
Peter Wu
90994b0d81 daemon: release resources at shutdown
This makes it easier to find real memory leaks with valgrind. After
calling the up_backend_unplug functions, you cannot restart it with
up_backend_coldplug since the lists are cleared.

Tested with Linux only (not on *BSD; dummy compiles).

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:16 +00:00
Peter Wu
71cbf8dfb9 linux: fix memleak when reading critical action
g_variant_get for string types must be freed as documented at
https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-strings
Since we just want to compare it, use a pointer as documented at
https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-pointers

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:05 +00:00
Bastien Nocera
6573310637 linux: Respect the CriticalPowerAction config option
It was documented, but the configuration was never actually read.

https://bugs.freedesktop.org/show_bug.cgi?id=82925
2014-09-02 21:56:38 +02:00
Bastien Nocera
bab2431c1e linux: Simplify list freeing 2014-06-24 16:41:48 +02:00
Bastien Nocera
135339acc1 daemon: Deprecate "IsDocked" property
The IsDocked property has been incorrect for a number of laptops for a
while, as it thought that laptops with hybrid graphics cards were always
docked.

The alternative would have been to use the platform/dock_station
devices, but those are only exported for ACPI docking stations.

Instead, whether an external display is attached (which isn't really
docking) should be checked in the same place where the policy depending
on the value should be applied, such as gnome-settings-daemon.

https://bugs.freedesktop.org/show_bug.cgi?id=36818
2014-05-07 09:27:24 +02:00
Richard Hughes
97ed6c4731 trivial: Fix a compile warning in the linux backend 2013-10-29 12:51:23 +00:00
Bastien Nocera
8460a10c5e linux: Remove debug 2013-10-17 14:41:55 +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
a7870229ee linux: Fix incorrect check for logind sleep methods
A simple reversed check...
2013-10-17 08:56:41 +02:00
Bastien Nocera
68b9975ad9 daemon: Add CriticalPowerAction
Paraphrasing from the configuration option:
The action to take when "TimeAction" or "PercentageAction" above has
been reached for the batteries (UPS or laptop batteries) supplying
the computer.

This is done 20 seconds after the warning-level variable got set
to UP_DEVICE_LEVEL_ACTION has been set, to give the opportunity
to front-ends to display a (short) warning.

This is only implemented for the Linux backend, using logind.
2013-10-14 11:06:53 +02:00
Bastien Nocera
91df125e39 daemon: Remove unneeded reset of priv struct members
It's already done by GObject.
2013-10-14 10:42:56 +02:00
Bastien Nocera
1ee642e705 daemon: Remove obsolete features 2013-10-14 10:42:55 +02:00
Bastien Nocera
5f26bc5caa daemon: Simplify _new() functions 2013-10-14 10:36:34 +02:00
Bastien Nocera
6abd4123ef linux: Opt-out of checking Watts Up devices earlier
Don't wait for tty events from udev if we're not going to
use the Watts Up device anyway. Cuts down on the possible wakeups.
2013-10-14 10:18:21 +02:00
Martin Pitt
ff39d23ff4 Fix test for logind availability
sd_booted() is not an appropriate check for whether we should talk to logind,
test for /run/systemd/seats/ instead.

For details, see:
<https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>
2013-03-21 07:10:18 +01:00
Richard Hughes
8bbf566dc8 Also deprecate running the powersave scripts
Over the years we've moved all the quirks to the kernel (and fixed most of the
issues properly) so on Fedora we've not actually been shipping any rules in
pm-utils for a couple of releaes now.

Dropping this functionality allows us to finally drop the pm-utils dep for upower.
2013-02-12 11:18:31 +00: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
b1f12feb1f Factor out the Logitech Unifying support to support other devices 2013-01-10 12:08:46 +00:00
Peter Hurley
9f31068707 Fix device matching for recent kernels
In recent kernels, hiddev* devices now have class "usbmisc", rather
than "usb" (see http://www.spinics.net/lists/linux-usb/msg62276.html).
This change translates into a change in SUBSYSTEM matching for hiddev*
devices. This fix addresses this for recent kernels while retaining
existing behavior. For reference, here is an attribute-walk for a
CyberPower CPS 1500C on kernel 3.7.0:

[Ubuntu bug #1091702: udev rules fail to match hid devices with new kernels]

udevadm info --attribute-walk --path=/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/usbmisc/hiddev0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/usbmisc/hiddev0':
    KERNEL=="hiddev0"
    SUBSYSTEM=="usbmisc"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0':
    KERNELS=="4-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1':
    KERNELS=="4-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1"
    ATTRS{idVendor}=="0764"
    ATTRS{speed}=="1.5"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="2"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}==" 50mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="c0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0001"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 1.10"
    ATTRS{urbnum}=="36"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="CPS"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0501"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}==" CP 1500C"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4':
    KERNELS=="usb4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idVendor}=="1d6b"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized_default}=="1"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="2"
    ATTRS{bcdDevice}=="0307"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:1d.2"
    ATTRS{version}==" 1.10"
    ATTRS{urbnum}=="50"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 3.7.0-030700-generic uhci_hcd"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0001"
    ATTRS{bDeviceClass}=="09"
    ATTRS{product}=="UHCI Host Controller"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2':
    KERNELS=="0000:00:1d.2"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{irq}=="18"
    ATTRS{subsystem_vendor}=="0x1028"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0300"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,000000ff"
    ATTRS{device}=="0x268a"
    ATTRS{msi_bus}==""
    ATTRS{local_cpulist}=="0-7"
    ATTRS{vendor}=="0x8086"
    ATTRS{subsystem_device}=="0x021e"
    ATTRS{numa_node}=="-1"
    ATTRS{d3cold_allowed}=="0"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-12-29 13:13:56 +00:00
Julien Danjou
9518459350 Add support for Logitech Unifying devices
This had support for Logitech devices working with an USB Unifying receiver.
This has been tested for at least the Logitech K750 solar keyboard, the M705
and the M505 mouses. Multiple receivers are also supported.

Signed-off-by: Julien Danjou <julien@danjou.info>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-10-30 20:05:30 +00:00
Jan Alexander Steffens (heftig)
ac4042ffaf Send resume signal when built with systemd and using pm-utils suspend
This case was apparently overlooked when adding systemd support.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-09-03 08:33:37 +01:00
Matthias Clasen
44189f8129 Use systemd for suspend and hibernate
When running under systemd, call into systemd for suspend and
hibernate instead of pm-utils. To capture resume events, install
a small script that gets executed by systemd after resume and
sends a dbus signal back to upower.

To make this work, the upower backends gain a new signal, ::resuming,
that they can optionally emit to signal that a resume happened.
Backends opt in to this by returning TRUE from up_backend_emits_resuming().
In this case, upower doesn't assume the sleep command to block until
resume, but instead waits for the ::resuming signal from the backend.

The only backend that uses this mechanism is the linux backend when
built with systemd support.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-07-11 18:11:39 +01:00
Kelly Anderson
5b2211cb23 Do not print error message for missing /etc/crypttab.
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-18 10:29:48 +00:00
Christian Seiler
ff23a9c6e2 Fix linux up_backend_supports_sleep_state() return code.
Under Linux, regardless of the exit code of /usr/bin/pm-is-supported, it will
always set CanSuspend and CanHibernate to true due to a logic error in
up_backend_supports_sleep_state in src/linux/up-backend.c: The 'ret' variable
is re-used for the return code without being re-initialized to false after the
call to g_spawn_command_line_sync.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2011-09-22 17:34:45 +02:00
Richard Hughes
b0bbb29df1 Add a config option 'EnableWattsUpPro' to disable the Watts Up Pro device
Annoyingly, the device used in the Watts Up Pro device seems to be a generic
USB->serial adaptor, which means it doesn't have a unique vendor and product
ID. If we try to probe for the WUP device, we can actually upset other devices
that are not expecing to be probed. This fixes #33846 although we actually
still need to be more strict in detecting a true WUP device.
2011-03-14 11:01:12 +00:00
Richard Hughes
38199e44ff Add an option for polling dock devices in UPower.conf, defaulting to false 2011-03-03 14:02:27 +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
Martin Pitt
c4a1c15d0c Fix UP_DAEMON_WATERLINE harder
Commmit fc7c6e003 had a thinko, UP_DAEMON_WATERLINE specifies (active
memory)/(available swap), not the other way around. So replace it with 99%
instead.

Also update the documentation of up_backend_get_used_swap() to explain what the
returned percentage actually means.
2010-07-07 15:08:43 +02:00
Martin Pitt
04eefe984c src/linux/up-backend.c: Add missing #include
We need sys/wait.h to get the WEXITSTATUS (and related) macros.
2010-07-07 11:20:47 +02:00
Richard Hughes
6118ac82ec Get the powersave command from the backend rather than hardcoding Linux specifics 2010-07-07 10:07:37 +01:00
Victor Lowther
6770e8cb34 Use pm-is-supported to test if various sleep modes are supported.
pm-is-supported does all the work upower was duplicating, and it handles more
use cases than the old upower code did.  No point in duplicating functionality.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2010-06-14 08:59:40 +01:00
Steven Walter
6bb6602c06 When calculating used swap space, only use anonymous pages
up_daemon_check_swap_space uses the Active: line from /proc/meminfo to
determine the amount of swap the system needs to be able to suspend.  However,
because Active: includes both anonymous and file-backed pages, this greatly
overestimates the amount of swap needed.  File-backed pages can be written back
to disk and so do not consume swap.

Instead, up_daemon_check_swap_space should use Active(anon): from /proc/meminfo
because only anonymous pages need to be written out to swap during a suspend.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2010-05-29 13:12:57 +01:00
Bastien Nocera
7019d214f8 Add battery query support for iDevices
https://bugs.freedesktop.org/show_bug.cgi?id=28286
Signed-off-by: Richard Hughes <richard@hughsie.com>
2010-05-28 13:49:56 +01:00
Richard Hughes
3dee7b22f8 Provide UpDaemon with C setters rather than relying on GObject properties 2010-04-19 17:05:59 +01:00
Richard Hughes
d1bd4d42fd Get the suspend and hibernate commands from the backend, rather than hardcoding Linux specifics 2010-03-29 16:42:35 +01:00
Richard Hughes
4b5dc883e6 Get the swap size from the backend, rather than hardcoding Linux specifics 2010-03-29 14:21:51 +01:00
Richard Hughes
0198498350 Get the encrypted swap status from the backend, rather than hardcoding Linux specifics 2010-03-29 14:18:42 +01:00
Richard Hughes
4620a9d122 Get the kernel sleep capabilities from the backend, rather than hardcoding Linux specifics 2010-03-29 14:16:11 +01:00
Richard Hughes
acfe9c3089 Update the Free Software Foundation address 2010-01-27 16:27:15 +00:00
Richard Hughes
c8cec18f06 trivial: DkpInput -> UpInput (no ABI or API break) 2010-01-18 13:15:47 +00:00
Richard Hughes
13f7addd62 trivial: switch to using the new marshal names internally (no ABI or API break) 2010-01-18 13:08:31 +00:00
Richard Hughes
25e51c9613 trivial: DkpDevice -> UpDevice (no ABI or API break) 2010-01-18 12:49:30 +00:00
Richard Hughes
d2550b4c78 trivial: DkpDaemon -> UpDaemon (no ABI or API break) 2010-01-18 12:35:47 +00:00
Richard Hughes
2562bc6aa6 trivial: DkpBackend -> UpBackend (no ABI or API break) 2010-01-18 12:32:06 +00:00
Richard Hughes
15ac5102c8 trivial: Rename a lot of the source files from dkp-foo to up-foo, no API or ABI changes 2010-01-18 12:26:55 +00:00
Renamed from src/linux/dkp-backend.c (Browse further)