Open pmav99 opened 3 years ago
Hi @pmav99, really I put that snippet into the README because it was a pain for me to get it to work and when I did, I didn't spend much time on perfecting it. If the solution you propose actually works, it certainly is superior to hardcoding. I will try it, thanks for the heads up!
Hi @pmav99, does the suggestion you made work for you?
I just tried this script:
#!/bin/bash
USERNAME=$(id -un)
USERID=$(id -u)
USERGROUP=$(id -g)
export XAUTHORITY=/home/$USERNAME/.Xauthority
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$USERID/bus
if [ "$(/usr/bin/id -u)" != "$USERID" ] ; then
sudo -u $USERNAME XAUTHORITY=/home/$USERNAME/.Xauthority DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$USERID/bus /usr/bin/notify-send.py "$@"
else
/usr/bin/notify-send.py "$@"
fi
Running sudo allUserNotifySend test
gives me an error, that there is no such thing as /run/user/0/bus, which makes sense, I guess.
So it clearly does not work on my system. Am I doing it wrong?
In the readme it is mentioned that in order to use the script for root you must hardcode the user name and the user id.
I think it is not really necessary to hardcode them. Is there something wrong with: