Score:0

Display a dialog when the user tries to shutdown from GNOME

de flag

Ubuntu 18.04 and 20.04

Hi,

I have a backup script running as a systemd service (borgmatic) with the use of systemd-inhibit to block the user to reboot/sleep/shutdown the computer. This works well.

Unfortunatelly, when the user tries to shutdown or reboot the computer in GNOME and nothing happens - i.e. the action silently fails - then the user is confused and eventually turns off the computer by long-press of the power button :-(

What I would like to achieve is to be able to open a dialog window (with zenity or notify-send) and tell the user to wait a bit - but only after he tries to shutdown.

I have experimented a bit with systemd --user service units to have zenity dialog displayed before various targets (gnome-session-shutdown.target), but that does not work as the shutdown procedure does not even starts... (And even if it started, the Xorg seems to be down already and zenity fails due to missing DISPLAY.)

When systemd-inhibit is active, then this is logged upon user trying to shutdown:

dec 26 21:41:18 t410s gnome-shell[8333]: endSessionDialog: No XDG_SESSION_ID, fetched from logind: 17
dec 26 21:41:19 t410s gnome-shell[8333]: endSessionDialog: No XDG_SESSION_ID, fetched from logind: 17
dec 26 21:41:22 t410s gnome-session[8314]: gnome-session-binary[8314]: WARNING: Shutdown failed: GDBus.Error:System.Error.ESTALE: Stale file handle
dec 26 21:41:22 t410s gnome-session-binary[8314]: WARNING: Shutdown failed: GDBus.Error:System.Error.ESTALE: Stale file handle
dec 26 21:41:22 t410s gnome-session-binary[8314]: Entering running state
dec 26 21:41:22 t410s gnome-shell[8333]: Ignored exception from dbus method: Gio.IOErrorEnum: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: 

Any idea how to display a message that backup is running?

EDIT: As @matigo suggested, I have implemented a work-around to display a different wallpaper while backup is in progress, and hope for the best...

in flag
Having run into a similar situation with my parents many years ago, I found the best option was to change the desktop background at the start of the backup, then restore it when complete. This made it abundantly clear that the system should not be shut down, and it generally worked. (My parents don’t read modals; they just click “OK” then complain to me when the computer doesn’t do what they *think* it’s going to do)
ar flag
@natigo if you convert your comment into an answer, possibly with a jpeg/PNG background file as an example, it will be great! Then OP can accept your answer as correct.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.