Reputation: 1483
I want to use PC A to send a notification to PC B via SSH, but I didn't see the notification on B.
ssh user_name@B_ip 'notify-send hello'
I also tried this: Use SSH on B to login A and then login B back and then send a notification. However it still didn't work. Didn't see the notification on B either.
Upvotes: 0
Views: 2819
Reputation: 3524
For showing notifications on remote machine in modern distributions (Debian 9 and newer) for current user.
export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
notify-send "Test Test" "testing..."
DISPLAY may be different or not set with Wayland.
Upvotes: 0
Reputation: 11
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:
@local represents your desktop and @remote represents the machine you ssh to.
@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
@local $ ssh -R localhost:7272:localhost:7272 $REMOTE_HOSTNAME
@remote $ socat ABSTRACT-LISTEN:/tmp/custom_dbus_name,fork TCP:localhost:7272
@remote $ export DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/custom_dbus_name,guid=5fe0907d81e722390f1ce02d6033ad76'
@remote $ notify-send "Hello, World"
Upvotes: 1