Linux desktop notifications
Relying in notify-send command I created a script so any user can send messages across all desktops of all the users currently logged in and using an X session.
#!/bin/bash
PATH=/usr/bin:/bin
XUSERS=($(who|grep -E "\(:[0-9](\.[0-9])*\)"|awk '{print $1$5}'|sort -u))
for XUSER in $XUSERS; do
NAME=(${XUSER/(/ })
DISPLAY=${NAME[1]/)/}
DBUS_ADDRESS=unix:path=/run/user/$(id -u ${NAME[0]})/bus
sudo -u ${NAME[0]} DISPLAY=${DISPLAY} DBUS_SESSION_BUS_ADDRESS=${DBUS_ADDRESS} PATH=${PATH} notify-send "$@"
done
Consider installing libnotify-bin package in case notify-send command is not available in your system.
You can also refer to the notify-send manpage for additional instructions on how to use this fantastic piece of code.
As an example, if we drop this line:
notify-send --urgency=normal --expire-time 1 "Heads up" "Incoming message…"
We will get something like:
That of course, sticks to our notification icon in the taskbar if we have it enabled:
For those who need it for future reference in case this post or this blog is lost, you can find it here:
https://github.com/aci686/Bash-Scripts/blob/master/notify-send-all.sh