From 9000327973121d4c6b33b5a6e5f900c31654e55a Mon Sep 17 00:00:00 2001 From: Vishweshwar Saran Singh Deo Date: Tue, 17 Oct 2023 19:49:57 +0530 Subject: [PATCH] [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 --- terminatorlib/plugins/save_last_session_layout.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/terminatorlib/plugins/save_last_session_layout.py b/terminatorlib/plugins/save_last_session_layout.py index 12a360ed..1d4e37c2 100644 --- a/terminatorlib/plugins/save_last_session_layout.py +++ b/terminatorlib/plugins/save_last_session_layout.py @@ -1,4 +1,5 @@ import os +import signal import sys # Fix imports when testing this file directly @@ -44,9 +45,21 @@ class SaveLastSessionLayout(plugin.Plugin): r = config.add_layout("SaveLastSessionLayout", current_layout) 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)