This repository has been archived on 2020-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
kernelcheck/notify_all

17 lines
625 B
Bash
Executable File

#!/bin/sh
# I (Michael De Roover) do not own this code. Many thanks to Stack Exchange user Andy (http://unix.stackexchange.com/users/187608/andy) for submitting it on http://unix.stackexchange.com/a/307097.
PATH=/usr/bin
XUSERS=($(who|egrep "\(:[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