notify users script
This commit is contained in:
1 parent
8379439eed
commit
d87d87b5a3
1 file changed
+25
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Send a notification message to all active graphical user sessions
|
||||||
|
# Usage: sudo ./notify_all_gui_users.sh "Your message here"
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 \"message\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MESSAGE="$1"
|
||||||
|
|
||||||
|
loginctl list-sessions --no-legend | while read -r session uid user seat tty; do
|
||||||
|
# Only graphical sessions
|
||||||
|
if [[ "$seat" == seat* ]]; then
|
||||||
|
BUS="/run/user/$uid/bus"
|
||||||
|
|
||||||
|
if [[ -S "$BUS" ]]; then
|
||||||
|
echo XNotify $user $uid $MESSAGE
|
||||||
|
sudo -u "$user" \
|
||||||
|
DBUS_SESSION_BUS_ADDRESS="unix:path=$BUS" \
|
||||||
|
notify-send "$MESSAGE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
Reference in new issue
Block a user