Skip to content

Instantly share code, notes, and snippets.

@shvchk
Last active September 11, 2023 13:06
Show Gist options
  • Save shvchk/2c184304dd88b8d53812afbd1a06256d to your computer and use it in GitHub Desktop.
Save shvchk/2c184304dd88b8d53812afbd1a06256d to your computer and use it in GitHub Desktop.
Send notification to all users via notify-send
#! /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
@rezzto
Copy link

rezzto commented Aug 10, 2022

tuu

@rezzto
Copy link

rezzto commented Aug 10, 2022

@rezzto ###

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment