Gnome: how to close all applications

gnomeshutdown

I've configured the Debian system on my netbook to shut down whenever the battery runs too low. Problem is, shutting down kills all running applications without giving them any chance to save any document I may be working on.

I'd like to write a script to "gently" close all open applications before shutdown kicks in, but I can't find a way to broadcast a "Close" message to all running applications in Gnome. Is there a way?

Thanks.

EDIT: Hibernating does not work on my netbook, so I can't use it as an alternative solution.

Best Answer

You could ask gnome to close the current session before the shutdown. Something like:

gnome-session-quit --logout --no-prompt
shutdown -h now

The command syntax can change according to gnome version (e.g. gnome-session-quit is the new name of gnome-session-save).

The --no-prompt force running applications to quit without user confirmation.

Related Question