I use a Logitech Performance MX wireless mouse, on Ubuntu 18.10 (Cosmic Cuttlefish), with Gnome 3.30.2 Ubuntu 20.04, with Gnome 3.36.2.

This mouse uses regular 1.2V AA NiMH rechargeable battery1, which usually lasts 3 months on a single charge

The problem is that Ubuntu's power system tries to detect how much voltage is left, and either the voltage sensors or the calculation algorithm is completely broken, so it starts to show notifications 6-8 weeks before it really runs out.

The worse part is that these notifications won't fade away after a few seconds like you'd expect. And to make it more infuriating, they have an audible alert, and show up after a every period of brief inactivity, which means you'll get dozens of notifications per day -- and you'll will need to click to dismiss them every single time.

I don't really need to be notified two months in advance on a mouse battery (or at all). When it runs out, I can just connect the cable. It's not like a printer, that you need to buy ink in advance.

It seems I'm not alone: tons of users have reported the same problem for years (1, or 2, or 3), but no solution.

It seems that upower developers recognize that the battery % should be ignored, but still emits warnings on low battery, and Gnome Settings Daemon doesn't offer any way to selectively disable or control these notifications:

$ upower --dump
Device: /org/freedesktop/UPower/devices/mouse_hidpp_battery_12  
  native-path:          hidpp_battery_12
  model:                Performance MX
  serial:               104a-8a-10-ee-9b
  power supply:         no
  updated:              Sun Jun  2 18:09:54 2019 (15 seconds ago)
  has history:          yes
  has statistics:       yes
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    battery-level:       critical
    percentage:          5% (should be ignored) ◀◀◀
    icon-name:          'battery-caution-symbolic'

Most of the workarounds I found involve patching gnome-settings-daemon (which I've done before, but for different reasons), or disabling power notifications entirely. I dislike both solutions, and wanted to selectively disable only mouse battery notifications, without touching anything else.

Thanks to a tip by @daFritz84, I decided to patch upowerd directly (although I used a different method than Stefan). The good news is that upower has few dependencies, so it's pretty straightforward to compile and patch your system.

Here's the patch to be applied over up-device.c:

--- up-device.c    2019-06-15 00:18:57.607554731 -0400
+++ up-device-silent.c    2019-06-15 00:19:03.207705276 -0400
@@ -63,6 +63,15 @@
     UpDeviceLevel warning_level, battery_level;
     UpExportedDevice *skeleton = UP_EXPORTED_DEVICE (device);

+    /* 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);
+        warning_level = UP_DEVICE_LEVEL_NONE;
+        up_exported_device_set_warning_level (skeleton, warning_level);
+        return;
+    }
     /* Not finished setting up the object? */
     if (device->priv->daemon == NULL)

Here's the step-by-step, tested on Ubuntu 18.04, 20.04, 20.10, and Manjaro (disclaimer: provided as is; you are responsible for checking the accuracy of the patch and ensure it won't ruin your system. Having said that, let me know in the comments below if it doesn't work for you, and I'll try to incorporate new distributions over time):

UPOWER_ORIG_VER=`upower --version`  
OS=`awk -F= '/^ID=/{print $2}' /etc/os-release`  
OS_VER=`awk -F= '/^VERSION_ID=/{print $2}' /etc/os-release | cut -d "\"" -f 2`

if [[ "$OS" == "manjaro" ]]  
    sudo pacman -S base-devel gtk-doc gobject-introspection git
elif [[ "$OS" == "ubuntu" ]]  
    sudo apt install git gtk-doc-tools gobject-introspection libgudev-1.0-dev libusb-1.0-0-dev autoconf libtool autopoint
    if [[ "$OS_VER" == "20.10" ]]
    echo "Unknown system; this script was only tested on ubuntu and manjaro."
    exit 1

# Download and patch upowerd
git clone  
cd upower/src  
patch < up-device.patch  
cd ..  

# Install upowerd
CUR_DATETIME=`date +%Y-%m-%d-%H%M%S`

pushd .  
cd src/.libs  
strip upowerd  
sudo chown root.root upowerd  
sudo mv upowerd ${PATH_UPOWERD}/upowerd-silent  
sudo mv upowerd upowerd-original-${CUR_DATETIME}  
sudo ln -s upowerd-silent upowerd  

# Install upower
pushd .  
cd tools/.libs  
strip upower  
sudo chown root.root upower  
sudo mv upower ${PATH_UPOWER}/upower-silent  
sudo mv upower upower-original-${CUR_DATETIME}  
sudo ln -s upower-silent upower  

# Restart upowerd
sudo systemctl restart upower

# Compare versions before/after (they will likely be different, but it depends on what your distro packages by default)
echo "---------------------------------------------------------------------------"  
echo "upower version BEFORE the update:"  
echo "${UPOWER_ORIG_VER}"  
echo "-------------------------------------"  
echo "upower version AFTER the update:"  
upower --version

To make it easier, here's the full script. You can run with:

wget -O - | bash  

Now enjoy your low battery spam-free system :) Let me know in the comments below if it works for you.

1My old Performance MX uses a replaceable battery; the Performance MX 3 uses an internal non-replaceable battery that lasts even longer

Blog Logo

Gui Ambros

Maker, engineer, ad:tech veteran. Incurable optimist. I was there when the web was born. Opinions here are my own. @GuiAmbros



/dev/random rants about technology, electronics, startups.

Back to Overview