On Mon, 06 Feb 2017, Carlos E. R. wrote:
On 2017-02-05 22:38, Michael Hamilton wrote:
I was looking for an answer to this quite recently, but found nothing inspiring, your question prompted me to revisit the issue.
There is an old question at stackexchange that addresses this issue:
http://unix.stackexchange.com/questions/2881/show-a-notification-across-all-...
None of the answers are truly satisfactory as there seems to be no universally correct, simple, standard, guaranteed equivalent to tty wall for X11. However, I did manage to get a modified solution to one of the suggestions to work on my system when run as root:
--- snip --- #!/bin/bash PATH=/usr/bin
XUSERS=($(who|egrep "\(:[0-9](\.[0-9])*\)"|awk '{print $1$NF}'|sort -u)) for XUSER in $XUSERS; do NAME=(${XUSER/(/ }) DISPLAY=${NAME[1]/)/} sudo -u ${NAME[0]} DISPLAY=${DISPLAY} \ notify-send "$@" done --- snip ---
If saved in notify-send-all, you can then do:
notify-send-all -i 'dialog-information' Warning 'Shutting down shortly.'
How do you tell which user to send to?
cer@Telcontar:~> notify-send --help Usage: notify-send [OPTION...] <SUMMARY> [BODY] - create a notification
Help Options: -?, --help Show help options
Application Options: -u, --urgency=LEVEL Specifies the urgency level (low, normal, critical). -t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification. -a, --app-name=APP_NAME Specifies the app name for the icon -i, --icon=ICON[,ICON...] Specifies an icon filename or stock icon to display. -c, --category=TYPE[,TYPE...] Specifies the notification category. -h, --hint=TYPE:NAME:VALUE Specifies basic extra data to pass. Valid types are int, double, string and byte. -v, --version Version of the package.
cer@Telcontar:~>
-u is for urgency, not user.
Ah, you set the DISPLAY variable and run as that user. Interesting...
What about those users that are not running a full desktop, but only a remote app via ssh? Mmm, perhaps on that terminal, via wall.
Agreed, it would be best to add a wall to cover tty users. The stackexchange posting also included setting a DBUS_SESSION_BUS_ADDRESS to /run/user/<uid>/bus, but that doesn't appear to be present on on my system. It does this as well as setting DISPLAY and using su - I'm not sure what setting the DBUS variable achieves. It would be great if DBUS or similar could be used to standardise how to broadcast a message. The scripted solution is rather convoluted and may be prone to error if the output from who contains anything unexpected. Cheers, Michael -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org