Firefox not closing properly at logout/shutdown

The standard session manager used by LXDE -
Posts: 2
Joined: Tue May 13, 2014 10:29 am

Firefox not closing properly at logout/shutdown

Postby dnc40085 » Tue May 13, 2014 10:57 am

Having a little past experience with Linux I recently decided to install Lubuntu 14.04 LTS to try and get away from windows and after much trial and tribulation I 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 see if there was logout script for lxde 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.

Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA

Re: Firefox not closing properly at logout/shutdown

Postby seppalta » Tue May 13, 2014 5:41 pm

I have occassionaly used the following script (withot the sleep entry) to shutdown:

Code: Select all

sleep 2s &&
xdotool key "super+t" &
sleep 1
xdotool key type "sudo shutdown -h 0" &
sleep 1
xdotool key "Return" &
sleep 1
xdotool key type "password" &
sleep 1
xdotool key "Return" &

It requires xdotool be installed, the keybind "super+t" to launch your terminal and "password" in the script replaced with "your password".

Posts: 2
Joined: Tue May 13, 2014 10:29 am

Re: Firefox not closing properly at logout/shutdown

Postby dnc40085 » Thu May 15, 2014 1:25 am

Thank you seppalta I'll give that a try.
if i'm not able to modify what happens during the execution of lxsession-logout, is there a way to make my own GUI menu with shutdown, reboot, logout, switch user, etc. that takes place of lxsession-logout simply?

I would modify the source code or write my own program to achieve my goal but I wouldn't know where to start, since I only have basic programming experience that's limited to microcontrollers via the Arduino IDE which is based on C++.

Posts: 591
Joined: Mon Apr 08, 2013 6:45 am

Re: Firefox not closing properly at logout/shutdown

Postby drooly » Thu May 15, 2014 7:16 am

there's some simple scripts around, one of them crunchbang's cb-exit; i have tweaked it succesfully in the past.
here it is:

Code: Select all

#!/usr/bin/env python2.7

import pygtk
import gtk
import os
import getpass

class cb_exit:
   def disable_buttons(self):

   def cancel_action(self,btn):

   def logout_action(self,btn):
      self.status.set_label("Exiting Openbox, please standby...")
      os.system("openbox --exit")

   def suspend_action(self,btn):
      self.status.set_label("Suspending, please standby...")
      os.system("systemctl suspend")

   def reboot_action(self,btn):
      self.status.set_label("Rebooting, please standby...")
      os.system("systemctl reboot")

   def shutdown_action(self,btn):
      self.status.set_label("Shutting down, please standby...")
      os.system("systemctl poweroff")

   def create_window(self):
      self.window = gtk.Window()
      title = "Log out " + getpass.getuser() + "? Choose an option:"
      self.window.set_size_request(500, 80)
      self.window.connect("delete_event", gtk.main_quit)
      windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)

      #Create HBox for buttons
      self.button_box = gtk.HBox()
      #Cancel button
      self.cancel = gtk.Button("_Cancel")
      self.cancel.connect("clicked", self.cancel_action)
      #Logout button
      self.logout = gtk.Button("_Log out")
      self.logout.connect("clicked", self.logout_action)
      #Suspend button
      self.suspend = gtk.Button("_Suspend")
      self.suspend.connect("clicked", self.suspend_action)
      #Reboot button
      self.reboot = gtk.Button("_Reboot")
      self.reboot.connect("clicked", self.reboot_action)
      #Shutdown button
      self.shutdown = gtk.Button("_Power off")
      self.shutdown.connect("clicked", self.shutdown_action)
      #Create HBox for status label
      self.label_box = gtk.HBox()
      self.status = gtk.Label()
      #Create VBox and pack the above HBox's
      self.vbox = gtk.VBox()
   def __init__(self):

def main():

if __name__ == "__main__":
    go = cb_exit()

Return to “LXSession (Lite)”

Who is online

Users browsing this forum: No registered users and 2 guests