4

Assuming my desktop environment is different than GNOME and that I do not have the predefined Super + N keyboard shortcut that comes with it, how may I expand a prompted notification bubble using the keyboard and without using the mouse?

Is it possible to create a custom keyboard shortcut to do this?

Pizza
  • 1,428

1 Answers1

3

Although not always natively supported, we can always make a tweak of our own and we'll create it in two parts:

  1. Create a desktop environment mouse action automation (essentially control your mouse actions using commands).
    This can be done using the xdotool, which needs to be installed first using this command:

    sudo apt-get install -y xdotool
    
  2. Create a custom keyboard shortcut that executes a command in Ubuntu.

Using xdotool to move your mouse position to a specific location on screen:

Sending the xdotool a mousemove command argument, followed by our desired location will cause the mouse position to move onto that point on screen:

xdotool mousemove X Y

where X is your horizontal position, and Y is your vertical position. The trick is to find where your notification appears, and choose a location that is inside the notification popup. Usually, 1000 70 is the default location, but that depends on your resolution and system settings.

How may I determine exactly where my notification appears?

You may use the notify-send command to invoke a notification!
The first argument would be the title, while the second argument is the body:

notify-send "my_title" "my_message"

Once the notification is gone, place a file or a folder in the middle of where it was, and start experimenting the xdotool command.
Whenever you're pointing over that file it will be highlighted, just as if you were hovering your mouse over it manually!

Final step - imitating a mouse hover on the notification so it expands:

If you've reached this part, you've probably noticed that the notification did not expand. That is because we also need to move our mouse a little on top of it to imitate a user's behavior of expanding it.

The solution? just use another xdotool mousemove command right after the first one was executed within the range of your notification pop up. For example:

xdotool mousemove 1000 70 && xdotool mousemove 900 70

If you see the result suites you, copy the working command and create a keyboard shortcut just as described in the link at the top of this answer.

Enjoy your new tweak!

Pizza
  • 1,428