#!/bin/bash

#Detect the name of the display in use from 0 to 10
for i in {0..10};
do
    #Detect the user using such display
    user=$(who | grep "(:${i})" | awk '{print $1}' | head -n 1)
    if [[ ! -z "$user" ]];
    then
        display="DISPLAY=:${i}"
        break
    fi
done

#Detect the id of the user
uid=$(id -u $user)


sudo -u $user $display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send "$@"
