Having a little past experience with Linux I recently decided to install Lubuntu 14.04 LTS to try and get away from windows and got most everything working except one thing so far... I have set Firefox to "Show my windows and tabs from last time" and that works just fine as long as I remember to close Firefox before I shutdown or restart, but if I forget, the next time I start Firefox 9/10 times it says that Firefox was not closed properly and sometimes forgets my tabs I had open.

I thought to try and find the logout script for lxde (if there is one) so I can maybe add a command such as "sleep 1" to delay logout for a second to allow Firefox to close properly, in my Google searches the only solution I could find that was close was Firefox not closed properly when logging out and I tried the solution suggested in that and couldn't get it to work and figured the reason why was because the solution was for gnome as opposed to lxde

So my question is, How can I add a delay during logout/shutdown to allow Firefox(or any other programs) to exit properly before continuing with logout/shutdown?

If there is already a solution to this issue, I apologize for not searching hard enough.

  • You can try this to run a script at logout Execute a script upon logout/reboot/shutdown in Ubuntu. And try first wmctrl -c firefox; without a delay in your script. – TuKsn May 10 '14 at 9:48
  • @Xubu-Tur Thank you for your response, I tried what you suggested and unfortunately it didn't solve the issue. I tried also adding a delay to see if the command isn't getting enough time to run but it still didn't work, it seems that the script isn't running before the kill command is issued by the logout process. – dnc40085 May 11 '14 at 5:08
  • Did you script work if you execute it manually? – TuKsn May 11 '14 at 9:50
  • Yes, the script does close Firefox correctly if I run it manually and I made sure that the addition to lightdm.conf (session-cleanup-script=/path/to/script) works correctly by pointing it to a script that runs the "touch" command to create a file on the desktop. It's just not running before the logout executes the kill command (or what ever command it uses to force exit) for Firefox. – dnc40085 May 11 '14 at 11:03
  • You can try the scripts below in my answer and create .desktop files for the scripts so you can use it instead of the standard buttons. – TuKsn May 12 '14 at 11:14

Perhaps a workaround:

script for logout:

wmctrl -c firefox && kill -SIGTERM $_LXSESSION_PID

script for shutdown:

wmctrl -c firefox && dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

For more options look at this answer: shutdown/reboot/suspend/hibernate without password

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.