Last active
September 11, 2023 13:06
-
-
Save shvchk/2c184304dd88b8d53812afbd1a06256d to your computer and use it in GitHub Desktop.
Send notification to all users via notify-send
This file contains 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
#! /usr/bin/env bash | |
user_list=($(who | grep -E "\(:[0-9](\.[0-9])*\)" | awk '{print $1 "@" $NF}' | sort -u)) | |
for user in $user_list; do | |
username=${user%@*} | |
display=${user#*@} | |
dbus=unix:path=/run/user/$(id -u $username)/bus | |
sudo -u $username DISPLAY=${display:1:-1} \ | |
DBUS_SESSION_BUS_ADDRESS=$dbus \ | |
notify-send "$@" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tuu