I know that I can send a notification to the user that will appear in the top-right corner of the screen an disappear on its own, like this:
notify-send "Device detected correctly"
However, this only works if I run it in a gnome-terminal
within the graphical environment.
I want to send a notification from a daemon process. It is running as a different user and it is started by systemd. How can I accomplish this?
The short answer is, you cannot. Notifications are a dbus service, which runs on the user's session bus. If you want to send a notification from a system service, to a user, you will need to have a daemon which runs as the user and communicates with the system service, and the user's session bus, to send the notification.
Using any hacks to get around this design, will almost certainly be a security vulnerability.