114

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?

screenshot

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.

Pablo Bianchi
  • 15,657
domo
  • 1,263
  • 2
  • 9
  • 8
  • 3
    @heynnema You did not read the whole post did you? – domo Dec 14 '17 at 06:14
  • Yes I did read it. Just replace the battery and you'll be good for another 3-6 months. The OS is doing what it was designed to do. You have 0% battery reading. Quit chasing your tail. – heynnema Dec 14 '17 at 15:59
  • 8
    @heynnema Well I've been closing these notifications for about, oh, 6 months now... and still going! Entirely pointless, and not something that happens in Windows. The bottom line is these low-powered mice & keyboards have much lower power thresholds than laptop batteries, and so, do not need these excessive warnings for close to half a year of usage... nor do we need condescending comments from people for whom this problem doesn't happen to affect. Actually it's a confirmed bug; bugzilla.kernel.org/show_bug.cgi?id=201445 – Domarius Oct 21 '18 at 22:21
  • 2
    @Domarius Thanks for the update. I edited the question and added a link to the bug report (although, I linked the launchpad report instead). – domo Oct 22 '18 at 13:12
  • 4
    @heynnema As of time of writing, the batteries have finally died. So 2 months after I made my comment, previous to which I had been seeing the notification for several months already! If the "OS is doing what it's designed to do" then this is evidence enough that it is "designed" badly.

    For the record, when I boot into Windows, it fades a "battery low warning" for a second and then fades away quickly. Much less intrusive.

    – Domarius Nov 20 '18 at 22:45
  • 3
    Thanks for this. My Logitech k400+ is at 10%, which I expect to last for a month or two. Constant reminders were a little excessive. :) – Jo-Erlend Schinstad May 21 '19 at 21:18
  • The bug you mentioned in your second update is nearly a year old now, and it's still unassigned, with importance undecided, and with not a damn thing done towards it. Clearly, the folks in the official channels don't care about a bug that is preventing me from using my computer. (It's not just about an annoying popup; that popup is preempting other programs that need to take control of the screen, knocking them out of use.) Has anyone at least figured out what bits of code are actually generating the notification, so I can look into either fixing or removing them? – Matthew Najmon Sep 28 '19 at 19:13
  • It's not in the notification-daemon or notify-osd packages. I know this because I checked, and my system didn't have notification-daemon on it at all, and I removed notify-osd, but it's still happening. – Matthew Najmon Sep 29 '19 at 00:03
  • 3
    They should have just added a "do not show this again" option for this device, or something like it that waits till the next recharge cycle, to the notification itself, if they wanted to follow any usability best practice. – matanox Apr 12 '21 at 07:17
  • I have a mouse with very low power consumption and my battery is at 10% with those notifications for almost a year. I am running Ubuntu 18.04. – ioaniatr May 25 '22 at 06:38
  • The solution below includes the notification of the laptop battery as well. Not only the mouse battery. So, as mentioned by @Jetblackstar is not a good option for a laptop or a desktop with multiple peripherals that have their own battery. If you turn off or decrease the percentage-low it will be applied to all the devices with a battery. I hope that this will be resolved on some point. – ioaniatr May 25 '22 at 06:48

7 Answers7

44

For Ubuntu 20.04 and later, go to Settings → NotificationsPower and toggle off the Notifications toggle.

Note that this, however, disables all power notifications.

  • 20
    That's exactly what I did. The problem is that it disabled ALL the power notifications, not only the ones related to the mouse. So if, for example, my laptop's battery is about to die, I won't get any notification. That's bad. – vvaltchev Jun 01 '20 at 13:43
  • 1
    Yeah that's true, I JUST WANTED to switch that mouse notification OFF anyhow. – roshansourav Jun 03 '20 at 13:20
  • 1
    This is what I need. Since laptops can show the battery life in the top-right corner, I think it does not really matter. – DrizzleX Jun 19 '20 at 02:19
  • 1
    Works on 19.10 as well. – AlikElzin-kilaka Sep 08 '20 at 09:59
  • 1
    Works for 18.04 after latest updates. – bonafernando Jan 07 '21 at 17:46
  • 1
    This is the only answer that worked for Ubuntu 20. Turning off notification popups does not work, so I had to turn off all Power notifications to get rid of those nasty nag popups. – 4LegsDrivenCat May 05 '21 at 14:03
  • It disables the notification popup, but there is still sound every time the mouse turns on. Had to also disable system sounds in the sound settings. – Yrogirg May 23 '21 at 08:33
  • 2
    This is a nice workaround on Ubuntu 20.04, however it disables all the power notifications, not only the ones related to mouse and keyboard. – Wizard79 Oct 11 '21 at 13:48
  • If it disabled all power messages, this solution is not usable, especially for laptops where low battery warning can be critical (lose data). So, why doesn't Gnome developers just add an option like "Notify low battery" in the Mouse settings? Is it one of the "my way or highway" attitude that they are famous for? – Damn Vegetables Jan 10 '23 at 11:23
31

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.

  • Thanks, that worked. The popup started to bug me again. org.gnome.settings-daemon.plugins.power contained a lot of goodness. – domo Mar 02 '18 at 08:22
  • 13
    This does not work in 18.04. Darn. Notification appears regardless of that setting. – Ohto Nordberg Sep 02 '18 at 14:11
  • 2
    Same here, also there is no "percentage-low" entry. – Matthias Urlichs Oct 07 '18 at 10:11
  • This doesnt work in Mint 19 either :( – Keltari Dec 01 '18 at 17:29
  • 5
    There was no percentage-low key on my Gnome 3.30 either and after some time spent Googling this problem it seems there is no other solution out there. Since the notifications were getting really annoying, I just disabled UPower by running systemctl stop upower and systemctl mask upower. Hopefully, there will be no negative consequences of this action. – livthomas Jan 04 '19 at 18:58
  • 1
    As a note to this, I just did it on Ubuntu 19.04, so if the setting wasn't there in 18.04, it's there now. :) – Jo-Erlend Schinstad May 21 '19 at 21:17
  • I was able to set this setting by running the command gsettings set org.gnome.settings-daemon.plugins.power percentage-low 4 on Ubuntu 19.04. – Wouter Sep 01 '19 at 07:44
  • 1
    @Wouter I upgraded to 19.04 to try this out but it doesn't work either. – Neptilo Nov 17 '19 at 22:17
  • This setting doesn't do anything on 18.04 for me either, so I solved this by using rechargeable batteries on my M570 and just swapping out the battery when it got "low" (even though as a 1.2V NiMH, it just looks low compared to 1.5V alkaline and could last plenty longer). – Andrew Mao Mar 26 '20 at 16:54
  • 1
    On RHEL/CentOS 8 there is no such option. Instead this can be done by editing /etc/UPower/UPower.conf – pooya13 May 24 '20 at 04:01
4

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

sudo nano /etc/UPower/UPower.conf

and change the attributes bellow:

PercentageLow=5
PercentageCritical=2

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.

ioaniatr
  • 1,301
  • 1
  • 11
  • 13
  • Does it apply to only input device batteries, or does it apply to laptop batteries, too? If it is the latter, this solution is unusable, because 5% for a laptop battery is too late. I think 10% is the marginal line where I could save the work or connect the charger. – Damn Vegetables Jan 10 '23 at 11:27
  • Yes, this will affect all types of batteries, including Laptop battery. However, it appears that it doesn't work anymore on Ubuntu 20.04 or the latest. I have set percentageLow=1, but still I am getting power notifications on 10%. Something else is handling batteries in 20.04 that I am currently running on a Laptop. – ioaniatr Sep 10 '23 at 17:43
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".

Dependancies:

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":
       time.sleep(.5)
       # 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()
session_bus.add_match_string_non_blocking("type='method_call',interface='org.freedesktop.Notifications',member='Notify',eavesdrop=true")
session_bus.add_message_filter(close_notification)
glib.MainLoop().run()
Pablo Bianchi
  • 15,657
  • 1
    Unfortunately, with Ubuntu 19.10 (default desktop environment), the notification is not a window listed by vmctrl -lx and so this nice script cannot work. Is there any other way to close that notification programmatically? – vvaltchev Apr 04 '20 at 19:38
  • I ended up doing this hack, which intercepts D-Bus messages to figure out what notifications to close: https://gist.github.com/eacousineau/63651e498ddc31a7c1478f8638d0fd2e#file-scrub_notifications-py Dunno how robust it is, only tested on Ubuntu 18.04, but mebbe it's useful? – eacousineau Nov 25 '20 at 22:18
3

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.

Pablo Bianchi
  • 15,657
J. Doe
  • 31
3

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

disable_mouse_notification.sh

#!/bin/bash
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 &quot;\&quot;&quot; -f 2

if [[ "$OS" == "manjaro" ]]
then
echo "Manjaro detected" sudo pacman -S base-devel gtk-doc gobject-introspection git PATH_UPOWERD="/usr/lib" PATH_UPOWER="/usr/bin" elif [[ "$OS" == "ubuntu" ]]
then
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" ]] then echo "Ubuntu version 20.10 (Groovy Gorilla) detected" PATH_UPOWERD="/usr/libexec" PATH_UPOWER="/usr/bin" else echo "Ubuntu version <= 20.04 detected" PATH_UPOWERD="/usr/lib/upower" PATH_UPOWER="/usr/bin" fi else
echo "Unknown system; this script was only tested on ubuntu and manjaro." exit 1 fi

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 ..
./autogen.sh ./configure make

Install upowerd

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

Install upower

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

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

Result:

$ upower --version

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

At least the notification is gone immediately.

Burak
  • 131
  • 2
  • Thanks a lot, two litte modifications:
    • git checkout tags/UPOWER_0_99_11 -b notification_patch (for Ubuntu 21.04)
    • add keyboards: if ((type == UP_DEVICE_KIND_MOUSE || type== UP_DEVICE_KIND_KEYBOARD) ...
    – krisek Sep 19 '21 at 09:55
  • The blog post seems to be updated so I recommend referring to it. I will keep this post as is because I know it worked for me, but anyone is welcome to edit and update. – Burak Sep 20 '21 at 05:26
  • This just worked perfectly for me (with no "symbol lookup error", although I edited the C by hand, not using the supplied patch), in 2024, even on Pop!OS 22.04 (derived from Ubuntu). See my comment on the linked blog post for what I had to change to get it to work on Pop!OS and with modern upowerd. – Jonathan Hartley Jan 05 '24 at 03:44
2

The solution mentioned in: https://wrgms.com/disable-mouse-battery-low-spam-notification/ 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!!

  • I think he updated the script that automates it. I just tried with Ubuntu 20.04.4 LTS and GNOME 3.36.8 and just used the wget....bash script command and after 6 minutes, it was patched and solved. All that for a stupid mouse alert....but anyway it's gone now. – Jon Grah Mar 23 '22 at 13:33