Interesting point, thanks for the clarifications. I thought that it would be as simple as setting the environmental variables DBUS_SESSION_BUS_ADRESS and DISPLAY at each unit file that you would want to receive notifications from.I thought that i might have not seen all the directives of systemd and perhaps there was one already to call an external script. But thanks anyway On 02/06/2015 09:23 PM, Mantas Mikulėnas wrote: > On Fri, Feb 6, 2015 at 5:26 PM, George Karakougioumtzis > <mad-proffes...@hotmail.com <mailto:mad-proffes...@hotmail.com>> wrote: > > Hi. Congrats for the near perfect job on systemd! I was searching > for a > directive to execute a script upon systemd service failure. I > would like > to receive desktop notifications about such failures. I stumbled upon > OnFailure and FailureAction but these have hardcoded list of actions? > > > One of those actions is "start an arbitrary unit", which could handle > notifications... Unfortunately it doesn't actually pass any failure > information to that unit. So, instead, you might have to watch the > system log (journal) for unit failure notices. (I would normally have > said that the journal makes it easy to filter for them, but quite > strangely, these ones don't have a MESSAGE_ID attached...) > > Maybe others will have better suggestions. > > > Any hints how to get notified (with notify-send most likely)? > > > systemd calling notify-send isn't going to happen – as a service, it > runs "outside" your desktop session, and has no access to its D-Bus > session bus, which tends to be started at a random address. (There > might even be several sessions, not just one!) And even considering > the future "user bus" plans (which would put the session bus at a > known fixed location), the whole idea of having a service inject > something into a desktop session is really ugly. Even Microsoft > realized that and implemented "session 0 isolation" in VIsta. > > In other words, such a notifier would need to be started from within > your desktop session, connect /to/ systemd (either by waiting for > signals on the system bus or by watching the journal messages), and > idle in background waiting for some unit to fail. With DBus it could > be a simple 10-line script, waiting for signals on one bus and calling > Notify() on another... > > -- > Mantas Mikulėnas <graw...@gmail.com <mailto:graw...@gmail.com>>
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel