diff --git a/README.md b/README.md index 79a320d8..4e90b8f7 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,7 @@ To reload css after changes - Delete/BackSpace: Close notification - Shift+C: Close all notifications - Shift+D: Toggle Do Not Disturb +- Ctrl+Z: Restore latest closed notification - Buttons 1-9: Execute alternative actions - Left click button / actions: Activate notification action - Middle/Right click notification: Close notification diff --git a/man/swaync.1.scd b/man/swaync.1.scd index 922d032b..51febb9f 100644 --- a/man/swaync.1.scd +++ b/man/swaync.1.scd @@ -43,6 +43,8 @@ swaync - A simple notification daemon with a GTK gui for notifications and the c *Shift+D*: Toggle Do Not Disturb +*Ctrl+Z*: Restore latest closed notification + *Buttons 1-9*: Execute alternative actions *Left click button / actions*: Activate notification action diff --git a/src/controlCenter/controlCenter.vala b/src/controlCenter/controlCenter.vala index 58ed078a..4693544c 100644 --- a/src/controlCenter/controlCenter.vala +++ b/src/controlCenter/controlCenter.vala @@ -97,6 +97,8 @@ namespace SwayNotificationCenter { HashTable noti_groups_name = new HashTable (str_hash, str_equal); + Queue notification_history = new Queue (); + const string STACK_NOTIFICATIONS_PAGE = "notifications-list"; const string STACK_PLACEHOLDER_PAGE = "notifications-placeholder"; @@ -253,6 +255,14 @@ namespace SwayNotificationCenter { case "Caps_Lock": this.set_visibility (false); return; + case "z": + if (state == Gdk.ModifierType.CONTROL_MASK) { + if (notification_history.length > 0) { + var first_in_history = notification_history.pop_head (); + add_notification (first_in_history.param); + } + } + return; } } @@ -648,6 +658,8 @@ namespace SwayNotificationCenter { foreach (var w in group.get_notifications ()) { var noti = (Notification) w; if (noti != null && noti.param.applied_id == id) { + notification_history.push_head (noti); + if (dismiss) { noti.close_notification (false); }