Skip to content

Commit

Permalink
Close notification with middle mouse button (#413)
Browse files Browse the repository at this point in the history
* Close notification with middle mouse button

Signed-off-by: Stian Onarheim <[email protected]>

* Fix linting issue

---------

Signed-off-by: Stian Onarheim <[email protected]>
Co-authored-by: Erik Reider <[email protected]>
  • Loading branch information
Feqzz and ErikReider authored May 3, 2024
1 parent 931bea2 commit 653058b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ To reload css after changes
- Shift+D: Toggle Do Not Disturb
- Buttons 1-9: Execute alternative actions
- Left click button / actions: Activate notification action
- Right click notification: Close notification
- Middle/Right click notification: Close notification
## Configuring
Expand Down
2 changes: 1 addition & 1 deletion man/swaync.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ swaync - A simple notification daemon with a GTK gui for notifications and the c

*Left click button / actions*: Activate notification action

*Right click notification*: Close notification
*Middle/Right click notification*: Close notification

# CONFIGURATION

Expand Down
13 changes: 9 additions & 4 deletions src/notification/notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,15 @@ namespace SwayNotificationCenter {
///

this.button_press_event.connect ((event) => {
if (event.button != Gdk.BUTTON_SECONDARY) return false;
// Right click
this.close_notification ();
return true;
// Close notification on middle and right button click
switch (event.button) {
case Gdk.BUTTON_MIDDLE:
case Gdk.BUTTON_SECONDARY:
this.close_notification ();
return true;
default:
return false;
}
});

// Adds CSS :hover selector to EventBox
Expand Down

0 comments on commit 653058b

Please sign in to comment.