Hi
I would like a cron job to pop up in the notifications, in the bottom right hand side of the screen. Is it possible?
Thank you, your help is much appreciated
I’m guessing…
If you’re not particular the positioning and format of the notification, you can invoke wall
http://man7.org/linux/man-pages/man1/wall.1.html
I suspect that if you want to be very specific about how your notification displays, you’ll need to look up the Developer documentation for the Desktop Environment, or maybe the Window Manager you want to target.
TSU
Which desktop? KDE? GNOME? Xfce?
The cron job runs as the user? As root?
Today most desktops use standard notification protocol, so it is possible to use the same tool in all of them. Although of course there could be exceptions so yes, information which desktop is needed.
It depends on exact goal.
If you want to do it for any user that is currently logged in without knowing user in advance - this is tricky. Notifications are displayed in context of individual login session; (root) cron job has no information about this session, so it has no way to know how to contact it. It is possible to write additional program that runs as part of user session, listens to announcements on system-wide bus and forwards these announcements to local notification service. I think I have even seen quick-n-dirty scripts that do it, but do not have reference.
If you only want to display notifications on your desktop, as i.e. user is fixed - you can use e.g. Send desktop notifications with cron | Enodev.fr / Christophe's log
Of course, robust script should check that session actually exist etc. You should replace i3 process with some indicative process of your user session. Today you can actually simply contact user systemd instance which should provide you with D-Bus address, like
bor@bor-Latitude-E5450:~$ systemctl show-environment --user | grep DBUS_SESSION_BUS_ADDRESS
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus
bor@bor-Latitude-E5450:~$
There has been a similiar discussion two months ago where I proposed something like this:
cp /home/**insert-you-user-here**/.Xauthority /root/; export DISPLAY=:0.0
kdialog --msgbox "`uname -a`"
kdialog --print-winid --passivepopup 'root says hello' --title 'kdialog Passive Popup over here'
First, I copy the secret key to thegraphical session of (insert-your-user-here) to root’s home and export the DISPLAY environment variable for root. This is based on two preconditions:
- A graphical X session of (insert-your-user-here)
is actually running - The display of the session is addressable by »:0.0« (usually true when only one such session is running)
- no graphical session is currently run by root (otherwise, that session could stop working because we overwrite its .Xauthority)
Second, I use the very flexible kdialog utility to open popups or alert boxex. Those should now be visible within the graphical desktop of (insert-your-user-here).
In the other thread, I also tried a xhost trick, but as user »arvidjaar« pointed out back theb, that was bogus.