Running startx on exit()

I’m wondering if this is possible - On a raspberry pi 2 I have my OF app set to run on boot. I’d like to provide a way for users to exit to the desktop environment from the application.

I know I can use system(“startx”) but I need this to run essentially after the OF application has closed - when placing it in exit() it gets called to early.
Wondering if anyone knows any magic tricks to make this happen? Or if it’s even possible?

Many thanks!

Depending on your application and performance needs, you might be able to run startx AND your app on startup … then the desktop will be there when your (fullscreen?) app closes.

you can just use a script that runs your app and then startx. you can’t run anything from the application itself once it’s finished

1 Like

Thanks for the tips. I was aiming to avoid having x running in the background due to performance concerns but I will test it and weigh up performance vs usability. Thanks again.

With @arturo’s solution, X won’t run in the background. If you have a bash script that launches on startup, first your program will run and the script will block until you exit your OF app, then X will run.

Amazing! thanks very much.