Could developers consider providing a way to shut off the mouse battery notification?


#1

I like to take mostly used batteries from wireless mics (not good to loose power in the middle of using a mic) and put them in my wireless mouse because such batteries can still last for weeks before being drained completely. Unfortunately, this has created an annoyance in Ubuntu MATE which faithfully reminds me about every 10 minutes that my wireless mouse battery is below 5%. That indicator stays on the screen until I close it.

The mouse battery indication seems to be tied to the laptop battery notification. I don’t want to get rid of the laptop battery notification because that is often useful to know that my laptop needs to be plugged in soon or it will shutdown. I don’t need a battery notification popping up a week to two or three weeks before it actually dies. Could these features either be separated or could I have the option of silencing only the mouse battery indicator. They really don’t help my productivity especially since I know the mouse won’t die anytime soon, and if it does, I have plenty of partially used batteries that I can pop into the mouse when it does die.

Thanks for considering this request.


#2

Hmm, that notification can be closed as soon as it opens (with the delay of 0.5 seconds).
Not sure if this is what the title says in the notification message because I don’t use wireless mouses.
I assume the notification looks like this https://askubuntu.com/questions/985963/disable-mouse-battery-low-spam-notification
So I assumed that the message summary is “Mouse battery low”.

Dependancies:.

sudo apt install python-dbus xdotool -y

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

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

def print_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)
os.system(“xdotool search --onlyvisible --class mate-notification-daemon windowclose”)

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(print_notification)

glib.MainLoop().run()[/code]
I hope it helps.


#3

Wow, thank you @Misko_2083. I had placed this post in the “Thoughts & Feedback” hoping that either in an updated package or in a future release developers might consider putting a setting into the Control Panel that would enable users to either turn off or turn on the mouse battery notification.

You, however, wrote a wonderful Python script that provided me with an immediate workaround that works well. The “Mouse battery low” notification will pop up but doesn’t even stay on the screen long enough for me to read the text. Although I would like to see a setting, your script makes me super happy.

Thank you so much for taking the time to write a Python script that addressed my use case. This is one of the things I love about the Linux community. Ubuntu MATE and its community for the win! Your script has worked every time without fail. Thank you so much. Have a wonderful day.