I have a bash script which monitors selected users (my children) and logs them out when they reach a daily time limit. It works great... about half the time. The same command on the same computer sometimes works and sometimes fails. When it fails, there are error messages, but I don't know what they mean, or how to solve the problem.
Here is the line where it fails:
Code:
(set -x; su -c "( export DISPLAY=$x11display ; aplay --quiet doorbell.wav & zenity --notification --text=\"Logging out...\" --timeout=5 --display=$x11display ; gnome-session-quit --logout --no-prompt )" $active_user) &>> timekeeper.log
When it works, aplay plays a bell sound, zenity produces a notification on the screen, and gnome-session-quit logs out the user.
When it doesn't work, I still get the bell sound, but the notification does not appear and it does not log out the user.
With set -x, it writes the command to a log file, which shows correct (valid) values of the variables $x11display and $active_user. It also shows two error messages. Here are the corresponding lines from the log file when it fails:
Code:
+ su -c '( export DISPLAY=:0 ; aplay --quiet doorbell.wav & zenity --notification --text="Logging out..." --timeout=5 --display=:0 ; gnome-session-quit --logout --no-prompt )' max
** (zenity:18631): WARNING **: Error showing notification: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
** (gnome-session-quit:18635): WARNING **: Failed to call logout: The name org.gnome.SessionManager was not provided by any .service files
Whenever the line fails, both errors always occur together, never just one or the other. If the failed command is repeated while the user remains logged in, it continues to fail every time. However, it the user logs out and later logs back in, it has about a 50-50 chance of working all right.
What the two error messages have in common is the part that says "The name org.xxx.yyy was not provided by any .service files". What does that mean, and is there a way to fix it?