10

I just installed Ubuntu 14.04 beta2 and out of 25 tries either logging out, shutting down or restarting, my session didn't close Firefox properly 23 times when exiting. The result is the Firefox tabs recovery page that never happens if I take the time to close Firefox manually beforehand.

Since it worked 2/25 times, it feels like a time problem where Ubuntu doesn't allow Firefox's process time to end (Ubuntu logs out in about 1-2s). I've never even received the "wait for Firefox? / shut down anyway?" dialogue box that I observed under 12.04.

So if I'm correct, how do I make it so that it waits? If not what is the issue and how do I solve the improper exiting?

I have no experience with managing profile or session config files and very little with bash (I understand it but am lousy at coding it). So if you can't answer but have an good article on how does the profiles/sessions work in Unix/Linux/Debian/Ubuntu (if the same) and/or how to make changes to the login/logout events, I'd be happy with that.

Edit: I made additional tests that further indicate it's a matter of time

  • wmctrl -c firefox; sleep 0.5; sudo shutdown now -r works fine 100%
  • wmctrl -c firefox; sleep 0.2; sudo shutdown now -r works fine 50%
  • wmctrl -c firefox; sudo shutdown now -r works fine 10%
  • sudo shutdown now -r& wmctrl -c firefox never seems to work...

So as a workaround, how can I write wmctrl -c firefox; sleep 0.5 in a file that resembles .profile or bash_logout but for session logout?

sinekonata
  • 572
  • 7
  • 23

1 Answers1

1

Apparently there is no dedicated file to write to like there used to be. It was the /etc/gdm/PostSession under Gnome but isn't available since apparently Unity. And placing a script under /etc/rc0.d/ and /etc/rc6.d/ will not work since they are only executed after Xserver is shut down.

However there is an event called gnome-save-yourself fired when gnome has been demanded to log out. I is what gedit for instance will implicitly call. And Seamus Phelan made a python script to listen to the event and run your script when caught.

Here's the link to the solution : Script Execution at user logout (non root user)

Follow instructions and then all you have to do is place your script that may look like this:

#! /bin/sh
#Requires wmctrl
wmctrl -c firefox;
gmusicbrowser -cmd "Quit";
exit 0;

where the option -c gently closes Firefox as does -cmd "Quit" for gMusicBroswer. Both Firefox and gMusicBrowser need to be closed properly which they do not.

A probably better way would be to check the use of SIGTERM, SIGKILL and kill timeout in Ubuntu and the programs but I don't know enough about it.

sinekonata
  • 572
  • 7
  • 23