[bug 843] 843-Plugin-SaveLastSessionLayout-not-saving-layout-when-user-logs-out-or-shutdown-or-restart #843

- fixed Plugin SaveLastSessionLayout not saving layout when user logs out or shutdown or restart
- signals added
This commit is contained in:
Vishweshwar Saran Singh Deo 2023-10-17 19:49:57 +05:30
parent 6d225c7aee
commit 9000327973

View File

@ -1,4 +1,5 @@
import os
import signal
import sys
# Fix imports when testing this file directly
@ -45,8 +46,20 @@ class SaveLastSessionLayout(plugin.Plugin):
config.save()
return True
def signal_handler(self,signum, frame):
signame = signal.Signals(signum).name
dbg('signal handler called:signal %s (%s)' %
(signame, signum))
self.save_session_layout()
def connect_signals(self):
dbg("SaveLastSessionLayout connect_signals")
signal.signal(signal.SIGTERM, self.signal_handler)
signal.signal(signal.SIGCHLD, self.signal_handler)
signal.signal(signal.SIGHUP, self.signal_handler)
n = 0
for term in Terminator().terminals:
dbg("SaveLastSessionLayout connect_signals to term num:(%d)" % n)