7

Is there an app/command that allows me to view recent notifications?

Preferably text-based.

I would also like to view the notification timeout for each notification. ;)

anonymous2
  • 4,325

3 Answers3

6

There isn't any command for retrieving previously send messages in Desktop Notifications Specification so my guess is that they are discarded after retrieving.

You can however observe these using dbus-monitor command, like this:

$ dbus-monitor "interface='org.freedesktop.Notifications'"

Sending simple notification:

$ notify-send "Hello there"

results with following information:

method call time=1555095758.597788 sender=:1.385 -> destination=:1.386 serial=6 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetServerInformation
method call time=1555095758.601101 sender=:1.385 -> destination=:1.386 serial=7 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   uint32 0
   string ""
   string "Hello there"
   string ""
   array [
   ]
   array [
      dict entry(
         string "urgency"
         variant             byte 1
      )
   ]
   int32 -1
signal time=1555095765.734845 sender=:1.386 -> destination=:1.385 serial=15 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=NotificationClosed
   uint32 1
   uint32 1

Time field is an UNIX timestamp, can be translated like this:

$ date -d @1555095765
Fri Apr 12 21:02:45 CEST 2019
Nykakin
  • 3,814
1

I've been using this for over a year on UbuntuMate 16/18

https://launchpad.net/~jconti/+archive/ubuntu/recent-notifications

http://ppa.launchpad.net/jconti/recent-notifications/ubuntu

anon
  • 11
1

If you want to do something with that data you may want some coding and not just a command line stdout, so I am using python here what you can modify to your needs. There is already a similar topic here: Listening to incoming libnotify notifications using DBus

I am copying some python code from there with some (python3) update:

import dbus
from dbus.mainloop.glib import DBusGMainLoop

def notifications(bus, message): print(message.get_args_list())

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 = glib.MainLoop() mainloop.run()

redseven
  • 842
  • 1
  • 8
  • 14