[Gambas-user] Saving settings on system shutdown

Benoît Minisini g4mba5 at gmail.com
Mon Oct 4 21:37:10 CEST 2021


Le 03/10/2021 à 12:59, Bruce Steers a écrit :
> 
> I have a program that starts with my system and runs in the background.
> 
> It has icons i can move and on exit it saves the positions.
> 
> I have noticed if i do not exit the program but shutdown the computer 
> the settings do not save.
> 
> Of course i could just save the settings on moving icons but i wondered 
> if there is a recommended method to catch an application exit due to a 
> shutdown?
> Does the system just kill the program?
> 
> I guessed DBus would probably be the best alternative way but wouldn't 
> hurt to ask the experts if there is already an easier way.
> 
> Thanks for any advice :)
> 
> BruceS
> 

QT4, QT5 and GTK+2 components handle the "X11 session management protocol".

https://www.x.org/releases/X11R7.7/doc/libSM/xsmp.html

To handle it with Gambas, you just have to define the 
Application.Restart property with a string array that defines the 
command that will be run to automatically restart your application the 
next time the desktop starts again.

When the desktop shutdowns, it is supposed to gracefully close the 
windows of your application, so that you can cancel the shutdown. If you 
do nothing, your application will be closed gracefully. It will be 
killed only if it does not answer to the window close events.

GTK+3 component does not support that protocol (hey, it's a modern 
toolkit!), and I don't think there is the equivalent on Wayland, but I 
may be wrong. I need more information about that.

Regards,

-- 
Benoît Minisini


More information about the User mailing list