Disable "Mouse battery low" spam notification

Countless times over the past few weeks I have been notified about the low battery in my wireless mouse. Every time it wakes up from sleeping mode and reconnects over Bluetooth I get a notification. I have gotten hundreds of notifications. I do not want them and I do not need them. Yes, battery is low, but at 0% (as reported) it will go on for another week at least. The notification has no timer and will stay visible until I close it.

How do I disable this torture?


Realizing I might sound like a grumpy old man I am not going to replace my batteries that are good for another month as a workaround. I am running Ubuntu 17.10 with GNOME Shell. I have no clue what is causing this. Pointers and suggestions will be greatly appreciated!

UPDATE: It turns out the mouse ran for another ten days or so after the initial notification. With the OS constantly reminding me that it will soon stop working. Wasting fine batteries is not a very good design. People should care about that and have an option to turn the notifications off.

UPDATE 2018-10-22: I asked some time ago. The marked correct answer might not apply anymore. It appears to be a bug in the gnome-settings-daemon. See the report for updates revolving this issue.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

for Ubuntu 20:
settings -> notifications -> power and then toggle off the notifiction-button .

Solution 2

OK, I hit the same issue. Reasons are similar; my Logitech M570 is fed on “dead” batteries as it lasts MONTHS on a very low voltage alkaline. So I use batteries in other things and keep the dead ones for my M570.

The best answer I’ve found was to lower the Power Plugins critical level warning. This way you can customise when it nags.

You need dconf for command line or dconf-editor for the GUI version (for GUI you’ll need to do sudo apt-get install dconf-tools, although that package may not be available for newer versions, so just get dconf-editor and its dependencies).

Setting is generically for batteries though, so if you’re on a laptop or a UPS then you will be altering the warning levels for those, which may be non ideal.

For Ubuntu 17.10 (Artful Aardvark) go to org → gnome → settings-daemon → plugins → power. Alter the “percentage-low” setting to what you want. I changed from 10% to 4%.

It is not a perfect answer if you have a laptop, but it is fine for a desktop computer and better than filling landfill with batteries or being nagged.

Solution 3

You could use a script that closes the message as soon as it opens (with the delay of 0.5 seconds, it takes time for the message window to open).
This is not perfect, because it closes the last notification window in the window stack. Therefore there is a small chance to close the wrong notification if it appears at almost the same time as the one with the message summary “Mouse battery low”.


sudo apt install python-dbus wmctrl -y

This one is for xfce. You’ll have to tweak it for gnome, if that is what you use.
For xfce next command closes the last notification window:

wmctrl -i -c $(wmctrl -lx | awk '/xfce4-notifyd\.Xfce4-notifyd/{print $1}' | tail -n 1)

awk filters the window(s) with the window class xfce4-notifyd.

For mate-desktop window class is mate-notification-daemon, I’m not sure for Gnome.

Change that line for your DE in the script.

Save next script, make it executable and set it to run on startup.

#!/usr/bin/env python
import glib
import dbus
import os
import time
from dbus.mainloop.glib import DBusGMainLoop

def close_notification(bus, message):
  keys = ["app_name", "replaces_id", "app_icon", "summary",
          "body", "actions", "hints", "expire_timeout"]
  args = message.get_args_list()
  if len(args) == 8:
    notification = dict([(keys[i], args[i]) for i in range(8)])
    if notification["summary"] == "Mouse battery low":
       # Adapt next command for your DE
       os.system("wmctrl -i -c $(wmctrl -lx | awk '/xfce4-notifyd\.Xfce4-notifyd/{print $1}' | tail -n 1)")

loop = DBusGMainLoop(set_as_default=True)
session_bus = dbus.SessionBus()

Solution 4

Ubuntu 18.04 on a desktop computer here, so I’m not having issues that laptop could potentially have with that solution.

  1. You can test whether what you made is working by restarting upower service:

    sudo systemctl restart upower
  2. I managed to solve it by altering upower’s config file:

    sudo nano /etc/dbus-1/system.d/org.freedesktop.UPower.conf

I simply commented out whole config, leaving empty
<busconfig></busconfig> tag.

Solution 5

As proposed in this post, you can edit the setting of UPower:

sudo nano /etc/UPower/UPower.conf

and change the attributes bellow:


Then restart the service:

sudo systemctl restart upower

This could disable the battery notifications, but still, keep in mind that on a Laptop machine or Desktop PC with multiple peripherals that have their own battery source this will disable the notifications for every device.

So, this will get rid of the annoying notifications, but it does not provide a complete solution.

I can confirm that this works on Ubuntu 18.04 and 20.04. Give it a try, it might work on 17.10 as well.

Solution 6

Copying the solution from a blog post. Use at your own risk.


set -e

# https://wrgms.com/disable-mouse-battery-low-spam-notification/

# Check which version you're using
upower --version  
UPOWER_ORIG_VER=`upower --version`

# Check Debian / Ubuntu vs. Arch Linux / Manjaro
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" ]]  
    echo "Manjaro detected"
    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 "Ubuntu version 20.10 (Groovy Gorilla) detected"
        echo "Ubuntu version <= 20.04 detected"
    echo "Unknown system; this script was only tested on ubuntu and manjaro."
    exit 1

# Download and patch upowerd
git clone https://gitlab.freedesktop.org/upower/upower  
cd upower/src  
wget https://gist.githubusercontent.com/guiambros/f2bf07f1cc085f8f0b0a9e04c0a767b4/raw/ef90dfcfa2489bab577bd984a6082abacdf8b0b1/up-device.patch  
patch < up-device.patch  
cd ..  

# Install upowerd
pushd .  
cd src/.libs  
strip upowerd  
sudo chown root.root upowerd  
sudo mv upowerd ${PATH_UPOWERD}/upowerd-silent  
sudo mv upowerd upowerd-original  
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  
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 "upower version BEFORE the update:"  
echo "${UPOWER_ORIG_VER}"  
echo "-------------------------------------"  
echo "upower version AFTER the update:"  
upower --version


$ upower --version

upower: symbol lookup error: upower: undefined symbol: up_client_get_devices2

At least the notification is gone immediately.

Solution 7

The solution mentioned in:
worked for me (on Ubuntu 18.04)

I too got the following error in the final step for the command "upower –version":
upower: symbol lookup error: upower: undefined symbol: up_client_get_devices2

Then I made the following changes as suggested in the comments section, i.e:

  1. Replaced "git clone https://gitlab.freedesktop.org/upower/upower" with "git clone –single-branch –branch UPOWER_0_99_7 https://gitlab.freedesktop.org/upower/upower" (since my upower version was 0.99.7)
  2. Installed ‘intltool’ using "sudo apt-get install intltool" before running "./autogen.sh"

After incorporating these changes, the error is gone and so is the mouse battery power notification!
Thank you Gui Ambros!!

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply