You are not logged in.

#1 2021-07-18 13:59:15

auipga
Member
Registered: 2016-12-08
Posts: 5

upower-ignore-low-hid

I modified the package aur/upower-nocritical based on
1. https://askubuntu.com/questions/985963/ … tification
2. https://wrgms.com/disable-mouse-battery … ification/

Todos:
- write correct PKGBUILD
- create working patch file
- publish to aur

Here is what I did to use this on my system (without aur)

Changes in PKGBUILD:

pkgname+="-ignore-low-hid"
pkgdesc+=" (With a patch to disable low battery hid)"
#source+=(0001-Ignore-low-mouse-battery.patch)

0001-Ignore-low-hid-battery.patch (this file isn't working. It just shows the code I manually pasted from this (mentioned in link 2). Line numbers may also not be 100% correct)

--- src/linux/up-device.c	2021-07-18 00:27:11.329004126 -0400
+++ src/linux/up-device.c	2021-07-18 00:27:51.785006055 -0400
@@ -67,6 +67,15 @@
 	UpDeviceLevel warning_level, battery_level;
 	UpExportedDevice *skeleton = UP_EXPORTED_DEVICE (device);
 
        /* Not finished setting up the object? */
        if (device->priv->daemon == NULL)
                return;

+        /* Disable warning notifications for wireless mice with rechargeable batteries */
+        int type = up_exported_device_get_type_ (skeleton);
+        int state = up_exported_device_get_state(skeleton);
+        if (type == UP_DEVICE_KIND_MOUSE && state == UP_DEVICE_STATE_DISCHARGING) {
+                warning_level = UP_DEVICE_LEVEL_NONE;
+                up_exported_device_set_warning_level (skeleton, warning_level);
+                return;
+        }
+
 	/* If the battery level is available, and is critical,
 	 * we need to fallback to calculations to get the warning
 	 * level, as that might be "action" at this point */

I ask for someone who can do this for me. I don't want to maintain this. I confess I skipped the reading "How to Request a Package" completely and also trying it for myself.
I'm willing to pay 20 $ in paypal to the person helping me with this.

Last edited by auipga (2021-07-21 15:41:23)

Offline

#2 2021-07-18 19:26:45

loqs
Member
Registered: 2014-03-06
Posts: 13,879

Re: upower-ignore-low-hid

You created the patch against the wrong path.  If you do not want to maintain it do not add it to AUR.

diff --git a/trunk/0001-Ignore-low-mouse-battery.patch b/trunk/0001-Ignore-low-mouse-battery.patch
new file mode 100644
index 0000000..6676eaa
--- /dev/null
+++ b/trunk/0001-Ignore-low-mouse-battery.patch
@@ -0,0 +1,20 @@
+diff --git a/src/up-device.c b/src/up-device.c
+index 37ec129..7afb42c 100644
+--- a/src/up-device.c
++++ b/src/up-device.c
+@@ -67,6 +67,15 @@ update_warning_level (UpDevice *device)
+ 	if (device->priv->daemon == NULL)
+ 		return;
+ 
++	/* Disable warning notifications for wireless mice with rechargeable batteries */
++	int type = up_exported_device_get_type_ (skeleton);
++	int state = up_exported_device_get_state(skeleton);
++	if (type == UP_DEVICE_KIND_MOUSE && state == UP_DEVICE_STATE_DISCHARGING) {
++		warning_level = UP_DEVICE_LEVEL_NONE;
++		up_exported_device_set_warning_level (skeleton, warning_level);
++		return;
++	}
++
+ 	/* If the battery level is available, and is critical,
+ 	 * we need to fallback to calculations to get the warning
+ 	 * level, as that might be "action" at this point */
diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index c78a16f..f05c655 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
@@ -1,32 +1,38 @@
-# Maintainer: Jan de Groot <jgc@archlinux.org>
+# Contributor: Jan de Groot <jgc@archlinux.org>
 
-pkgname=upower
+pkgname=upower-ignore-low-hid
+_pkgname=upower
 pkgver=0.99.12
 pkgrel=2
-pkgdesc="Abstraction for enumerating power devices, listening to device events and querying history and statistics"
+pkgdesc="Abstraction for enumerating power devices, listening to device events and querying history and statistics  (With a patch to disable low battery hid)"
 url="https://upower.freedesktop.org"
 arch=(x86_64)
 license=(GPL)
 depends=(systemd libimobiledevice libgudev)
 makedepends=(docbook-xsl gobject-introspection python git gtk-doc)
+conflicts=($_pkgname)
+provides=($_pkgname)
 backup=(etc/UPower/UPower.conf)
 _commit=0f2837acded0bf82acedf5caafc81684e1919c89
-source=("git+https://gitlab.freedesktop.org/upower/upower.git#commit=$_commit")
-md5sums=('SKIP')
+source=("git+https://gitlab.freedesktop.org/upower/upower.git#commit=$_commit"
+         0001-Ignore-low-mouse-battery.patch)
+md5sums=('SKIP'
+         '8f71f34c384b20e50f5e7e2569db965b')
 
 pkgver() {
-  cd $pkgname
+  cd $_pkgname
   git describe --tags | sed -e 's/UPOWER_//' -e 's/_/\./g' -e 's/-/+/g'
 }
 
 prepare() {
-  cd $pkgname
+  cd $_pkgname
+  git apply ../0001-Ignore-low-mouse-battery.patch
   sed -e 's|libplist >= 0.12|libplist-2.0 >= 2.2|' -i configure.ac # support libplist 2.2
   NOCONFIGURE=1 ./autogen.sh
 }
 
 build() {
-  cd $pkgname
+  cd $_pkgname
   ./configure \
     --prefix=/usr \
     --sysconfdir=/etc \
@@ -38,6 +44,6 @@ build() {
 }
 
 package() {
-  cd $pkgname
+  cd $_pkgname
   make DESTDIR="$pkgdir" install
 }

Offline

Board footer

Powered by FluxBB