Created
April 5, 2019 12:33
-
-
Save TopperBG/41449f4ed68cf692774eaabe69216e1f to your computer and use it in GitHub Desktop.
notify-send to all users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Copy the above code into a file named "notify-send-all", make it executable and copy it to /usr/local/bin or /usr/bin (as you like). Then run it e.g. as root in a console session like this: | |
notify-send-all -t 10000 "Warning" "The hovercraft is full of eels!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment