Is there a way to view notification history?

Take Recent Notifications.

screenshot recent notifications

In a terminal run:

sudo add-apt-repository ppa:jconti/recent-notifications
sudo apt-get update
sudo apt-get install indicator-notifications

Alternatively you could download the package directly on the launchpad-site. For Ubuntu 11.10 Oneiric on an i386-machine choose indicator-notifications_0.1.4-2~ppa~oneiric_i386.deb. (Don't install recent-notifications)

After installing run Alt+F2 unity --replace.

You will find a little mailbox in the panel:

recent notifications in panel

It is possible to align the icon to your desktop theme, i. e. when you use Faenza:

mkdir ~/.icons/Faenza/status/scalable
cp /usr/share/icons/Faenza/status/scalable/user-available-symbolic.svg ~/.icons/Faenza/status/scalable/indicator-notification-unread.svg
cp /usr/share/icons/Faenza/status/scalable/user-away-symbolic.svg ~/.icons/Faenza/status/scalable/indicator-notification-read.svg

new Faenza icons

To stop it you need to unistall it:

sudo apt-get purge indicator-notifications

Then again run Alt+F2 unity --replace.

To remove the ppa run:

sudo add-apt-repository -r ppa:jconti/recent-notifications

The comment linked here, Is there a way to view notification history?, asked:

Can this be done without adding another PPA?

Yes


Open two terminal windows (Ctrl+Alt+T+T). The extra window is needed only for test purposes.


Monitor notifications in one of the terminal windows with:

dbus-monitor "interface='org.freedesktop.Notifications'"    |     \
grep --line-buffered  "member=Notify\|string"

(to stop it, close the window or type Ctrl+C)

Note that running this script only shows those notifications occurring from the time it is started and must be run prior to the processes and aps. for which the history is desired. If the terminal window has an insufficient scrollback size either change the scrollback lines in Edit > Profile Preferences > Scrolling or record the history as described next.

To record the output in a permanent log just redirect it to a file by adding >>path/filename.ext to the end of the grep line. To record and view the notices append | tee >>path/filename.ext to the grep line.


Test it.

  1. Using Pangolin 12.04 Live SD/USB
  2. Turn wireless networking off & on.
  3. Use the other terminal window to make some other notifications with:
    for i in {0..100..20};
         do
               killall notify-osd;
               notify-send "testing $i" $i;
               sleep 0.5;
         done

Results

Judicious use of grep and sed etc. can pretty print the notifications that are crudely shown below for these monitored examples. The text that matches the graffiti in the notification pop-up bubbles is shown in bold. The two strings preceding those are the ap. making the graffiti (ie. "NetworkManager" or "notify-send") and the name of the icon, if any, (ie. "notification-network-wireless-disconnected") to show in the pop-up bubble.

   string ":1.380"
method call sender=:1.14 -> dest=:1.379 serial=8691
                path=/org/freedesktop/Notifications;
                         interface=org.freedesktop.Notifications; member=Notify
   string "NetworkManager"
   string "notification-network-wireless-disconnected"
   string "MissingLink"
   string "Disconnected - you are now offline"
         string "urgency"
         string "transient"
method call sender=:1.14 -> dest=:1.379 serial=8782 
                path=/org/freedesktop/Notifications;
                         interface=org.freedesktop.Notifications; member=Notify
   string "NetworkManager"
   string "notification-network-wireless-full"
   string "MissingLink"
   string "Connection Established"
         string "urgency"
         string "transient"
method call sender=:1.386 -> dest=:1.389 serial=7 
                path=/org/freedesktop/Notifications;
                         interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   string ""
   string "testing 0"
   string "0"
         string "urgency"

. . .

    method call sender=:1.426 -> dest=:1.429 serial=7
                path=/org/freedesktop/Notifications;
                         interface=org.freedesktop.Notifications; member=Notify
       string "notify-send"
       string ""
       string "testing 80"
       string "80"
             string "urgency"
    method call sender=:1.430 -> dest=:1.433 serial=7
                path=/org/freedesktop/Notifications;
                         interface=org.freedesktop.Notifications; member=Notify
       string "notify-send"
       string ""
       string "testing 100"
       string "100"
             string "urgency"

cross references:
... to be done ...