sys-power/upower: Consider pending-charge when calculating
authorPacho Ramos <pacho@gentoo.org>
Sun, 20 Jan 2019 13:36:50 +0000 (14:36 +0100)
committerPacho Ramos <pacho@gentoo.org>
Sun, 20 Jan 2019 13:40:34 +0000 (14:40 +0100)
Thanks-to: Maik
Closes: https://bugs.gentoo.org/671570
Package-Manager: Portage-2.3.55, Repoman-2.3.12
Signed-off-by: Pacho Ramos <pacho@gentoo.org>
sys-power/upower/files/upower-0.99.9-pending-charge1.patch [new file with mode: 0644]
sys-power/upower/files/upower-0.99.9-pending-charge2.patch [new file with mode: 0644]
sys-power/upower/upower-0.99.9-r1.ebuild [new file with mode: 0644]

diff --git a/sys-power/upower/files/upower-0.99.9-pending-charge1.patch b/sys-power/upower/files/upower-0.99.9-pending-charge1.patch
new file mode 100644 (file)
index 0000000..9ce91c1
--- /dev/null
@@ -0,0 +1,33 @@
+From a074a5462ab9749ad4aaca52e0202602897660aa Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= <jprvita@endlessm.com>
+Date: Thu, 1 Nov 2018 14:45:28 -0700
+Subject: [PATCH] daemon: Make comment more succinct
+
+This will help make it more clear when adding an extra state on the
+following commit. It also makes the language consistent between the
+different lines. There are no changes on the meaning of these lines nor
+any functional changes on this commit.
+---
+ src/up-daemon.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/up-daemon.c b/src/up-daemon.c
+index 1a5dddc..95fff6b 100644
+--- a/src/up-daemon.c
++++ b/src/up-daemon.c
+@@ -209,9 +209,9 @@ up_daemon_update_display_battery (UpDaemon *daemon)
+                   power_supply == FALSE)
+                       continue;
+-              /* If one battery is charging, then the composite is charging
+-               * If all batteries are discharging, then the composite is discharging
+-               * If all batteries are fully charged, then they're all fully charged
++              /* If one battery is charging, the composite is charging
++               * If all batteries are discharging, the composite is discharging
++               * If all batteries are fully charged, the composite is fully charged
+                * Everything else is unknown */
+               if (state == UP_DEVICE_STATE_CHARGING)
+                       state_total = UP_DEVICE_STATE_CHARGING;
+-- 
+2.18.1
+
diff --git a/sys-power/upower/files/upower-0.99.9-pending-charge2.patch b/sys-power/upower/files/upower-0.99.9-pending-charge2.patch
new file mode 100644 (file)
index 0000000..a79ebac
--- /dev/null
@@ -0,0 +1,48 @@
+From a074631c0b1748c8a791c4f0dad99da75805a328 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= <jprvita@endlessm.com>
+Date: Mon, 15 Oct 2018 17:05:27 -0700
+Subject: [PATCH] daemon: Consider pending-charge when calculating the display
+ state
+
+Without this change if all batteries in the system are in the
+pending-charge state, the display device state is set to unknown, and
+its icon to battery-missing-symbolic.
+
+This change makes the pending-charge state be considered when
+calculating the DisplayDevice state, setting it to pending-charge if at
+least one battery in the system is pending-charge and no other is
+charging or discharging.
+
+Closes: #81
+Closes: #19
+---
+ src/up-daemon.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/up-daemon.c b/src/up-daemon.c
+index 95fff6b..690f379 100644
+--- a/src/up-daemon.c
++++ b/src/up-daemon.c
+@@ -210,14 +210,18 @@ up_daemon_update_display_battery (UpDaemon *daemon)
+                       continue;
+               /* If one battery is charging, the composite is charging
+-               * If all batteries are discharging, the composite is discharging
++               * If all batteries are discharging or pending-charge, the composite is discharging
+                * If all batteries are fully charged, the composite is fully charged
++               * If one battery is pending-charge and no other is charging or discharging, then the composite is pending-charge
+                * Everything else is unknown */
+               if (state == UP_DEVICE_STATE_CHARGING)
+                       state_total = UP_DEVICE_STATE_CHARGING;
+               else if (state == UP_DEVICE_STATE_DISCHARGING &&
+                        state_total != UP_DEVICE_STATE_CHARGING)
+                       state_total = UP_DEVICE_STATE_DISCHARGING;
++              else if (state == UP_DEVICE_STATE_PENDING_CHARGE &&
++                       (state_total == UP_DEVICE_STATE_UNKNOWN || state_total == UP_DEVICE_STATE_PENDING_CHARGE))
++                      state_total = UP_DEVICE_STATE_PENDING_CHARGE;
+               else if (state == UP_DEVICE_STATE_FULLY_CHARGED &&
+                        state_total == UP_DEVICE_STATE_UNKNOWN)
+                       state_total = UP_DEVICE_STATE_FULLY_CHARGED;
+-- 
+2.18.1
+
diff --git a/sys-power/upower/upower-0.99.9-r1.ebuild b/sys-power/upower/upower-0.99.9-r1.ebuild
new file mode 100644 (file)
index 0000000..c154b14
--- /dev/null
@@ -0,0 +1,98 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit systemd xdg-utils
+
+DESCRIPTION="D-Bus abstraction for enumerating power devices, querying history and statistics"
+HOMEPAGE="https://upower.freedesktop.org/"
+
+# No tarball released, use the same commit as Fedora
+#SRC_URI="https://${PN}.freedesktop.org/releases/${P}.tar.xz"
+COMMIT="2282c7c0e53fb31816b824c9d1f547e8"
+SRC_URI="https://gitlab.freedesktop.org/upower/upower/uploads/${COMMIT}/${P}.tar.xz"
+
+LICENSE="GPL-2"
+SLOT="0/3" # based on SONAME of libupower-glib.so
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
+
+# gtk-doc files are not available as prebuilt in the tarball
+IUSE="doc +introspection ios kernel_FreeBSD kernel_linux selinux"
+
+COMMON_DEPS="
+       >=dev-libs/dbus-glib-0.100
+       >=dev-libs/glib-2.34:2
+       sys-apps/dbus:=
+       introspection? ( dev-libs/gobject-introspection:= )
+       kernel_linux? (
+               virtual/libusb:1
+               virtual/libgudev:=
+               virtual/udev
+               ios? (
+                       >=app-pda/libimobiledevice-1:=
+                       >=app-pda/libplist-1:=
+                       )
+               )
+"
+RDEPEND="
+       ${COMMON_DEPS}
+       selinux? ( sec-policy/selinux-devicekit )
+"
+DEPEND="${COMMON_DEPS}
+       doc? ( dev-util/gtk-doc )
+       dev-libs/libxslt
+       app-text/docbook-xsl-stylesheets
+       dev-util/intltool
+       >=sys-devel/gettext-0.17
+       virtual/pkgconfig
+"
+
+QA_MULTILIB_PATHS="usr/lib/${PN}/.*"
+
+DOCS=( AUTHORS HACKING NEWS README )
+
+PATCHES=(
+       # daemon: Consider pending-charge when calculating the display state
+       # (from 'master')
+       "${FILESDIR}/${P}-pending-charge1.patch"
+       "${FILESDIR}/${P}-pending-charge2.patch"
+)
+
+src_prepare() {
+       default
+       xdg_environment_reset
+       sed -i -e '/DISABLE_DEPRECATED/d' configure || die
+}
+
+src_configure() {
+       local backend
+
+       if use kernel_linux ; then
+               backend=linux
+       elif use kernel_FreeBSD ; then
+               backend=freebsd
+       else
+               backend=dummy
+       fi
+
+       local myeconfargs=(
+               --disable-static
+               --disable-tests
+               --enable-man-pages
+               --libexecdir="${EPREFIX}"/usr/lib/${PN}
+               --localstatedir="${EPREFIX}"/var
+               --with-backend=${backend}
+               --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
+               --with-systemdutildir="$(systemd_get_utildir)"
+               $(use_enable doc gtk-doc)
+               $(use_enable introspection)
+               $(use_with ios idevice)
+       )
+       econf "${myeconfargs[@]}"
+}
+
+src_install() {
+       default
+       find "${ED}" -name '*.la' -delete || die
+       keepdir /var/lib/upower #383091
+}