I would like to give out a notification on screen by a script that is running by root on Ubuntu 14.04.
I tried this:
#!/bin/bash
MAINUSER=$(cat /etc/passwd|grep 1000|sed "s/:.*$//g")
su $MAINUSER -c 'notify-send "starting some scan... "'
#....
su $MAINUSER -c 'notify-send "scan finished "'
which works fine and creates a notification, if you run it as root in a terminal, that was started in the desktop screen, but it doesn't if you change to another screen with Ctrl+Alt+F1 to start it from there as root.
I also tried it with export DISPLAY=:0; sudo -E -u rubo77 notify-send, but that didn't change the behaviour either.
I would like to add it here in my script to run rkhunter regularely on a desktop system
relevant discussion: http://chat.stackexchange.com/rooms/17882/discussion-between-rubo77-and-muru
I also tried to use xuserrun instead, but the same result