From 50f258f36f8908bdfca35495199f7506f2f19333 Mon Sep 17 00:00:00 2001 From: eshanized Date: Wed, 1 Jan 2025 09:20:06 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore:=20better=20for=20error=20?= =?UTF-8?q?hadling=20and=20some=20minor=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snigdhaos-welcome/snigdhaos-welcome.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/usr/share/snigdhaos-welcome/snigdhaos-welcome.py b/usr/share/snigdhaos-welcome/snigdhaos-welcome.py index b195aed..eda244d 100644 --- a/usr/share/snigdhaos-welcome/snigdhaos-welcome.py +++ b/usr/share/snigdhaos-welcome/snigdhaos-welcome.py @@ -628,13 +628,25 @@ class Main(Gtk.Window): return None def startup_toggle(self, widget): - if widget.get_active() is True: - if os.path.isfile(GUI.dot_desktop): - shutil.copy(GUI.dot_desktop, GUI.autostart) - else: - if os.path.isfile(GUI.autostart): - os.unlink(GUI.autostart) - self.save_settings(widget.get_active()) + try: + # Check if the toggle button is active + if widget.get_active(): + # If active, copy the .desktop file to autostart location + if os.path.isfile(GUI.dot_desktop): + shutil.copy(GUI.dot_desktop, GUI.autostart) + print(f"[INFO]: {GUI.dot_desktop} copied to {GUI.autostart}") + else: + # If inactive, remove the autostart file if it exists + if os.path.isfile(GUI.autostart): + os.unlink(GUI.autostart) + print(f"[INFO]: {GUI.autostart} removed") + + # Save the settings based on the widget state (active or not) + self.save_settings(widget.get_active()) + + except Exception as e: + # Log any errors that occur during the operation + print(f"[ERROR]: Error in startup_toggle: {e}") def save_settings(self, state): with open(GUI.Settings, "w") as f: