Notifications are sent via dbus (user session). You need to to tunnel the dbus socket over SSH so that a program running on another computer can send notification to your desktop.
The workflow is:
- Expose dbus socket to a local TCP port (only available from localhost)
- Reverse tunnel this local TCP port on the remote machine (using SSH)
- On the remote machine, expose this TCP port as an abstract socket
- Tell notify-send which dbus session to connect (the created abstract socket)
@local represents your desktop and @remote represents the machine you ssh to.
- Forward local port :7272 to dbus abstract socket (guid will be used later)
@local $ echo $DBUS_SESSION_BUS_ADDRESS
unix:abstract=/tmp/dbus-pH1JnDeLNA,guid=5fe0907d81e722390f1ce02d6033ad76
@local $ socat TCP-LISTEN:7272,reuseaddr,fork ABSTRACT-CONNECT:/tmp/dbus-pH1JnDeLNA
- Revert forward port 7272 from remote host (replace $REMOTE_HOSTNAME)
@local $ ssh -R localhost:7272:localhost:7272 $REMOTE_HOSTNAME
- Forward abstract socket to localhost:7272
@remote $ socat ABSTRACT-LISTEN:/tmp/custom_dbus_name,fork TCP:localhost:7272
- Launch notify-send
@remote $ export DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/custom_dbus_name,guid=5fe0907d81e722390f1ce02d6033ad76'
@remote $ notify-send "Hello, World"