Skip to content

Instantly share code, notes, and snippets.

@impshum
Last active September 9, 2021 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save impshum/f2f13f6d4bd04f1fe774ba8596f22408 to your computer and use it in GitHub Desktop.
Save impshum/f2f13f6d4bd04f1fe774ba8596f22408 to your computer and use it in GitHub Desktop.
import gi.repository.GLib
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import pyautogui
import time
from signal import signal, SIGINT
from sys import exit
def handler(signal_received, frame):
print('\nShutting down')
exit(0)
def main():
signal(SIGINT, handler)
print('Running\nPress CTRL-C to exit or enter "notify-send impshum" in another terminal tab/window to test')
screen_w, screen_h = pyautogui.size()
def notifications(bus, message):
args = message.get_args_list()
if args[0] == 'Brave' or args[3] == 'impshum':
time.sleep(.2)
mouse_x, mouse_y = pyautogui.position()
pyautogui.click(screen_w - 50, 50, button='right')
pyautogui.moveTo(mouse_x, mouse_y)
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_match_string_non_blocking("eavesdrop=true, interface='org.freedesktop.Notifications', member='Notify'")
bus.add_message_filter(notifications)
mainloop = gi.repository.GLib.MainLoop()
mainloop.run()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment