mirror of
https://github.com/Snigdha-OS/snigdhaos-welcome.git
synced 2025-09-20 22:14:56 +02:00
🧹 chore: better for error hadling and some minor improvements
This commit is contained in:
@@ -628,13 +628,25 @@ class Main(Gtk.Window):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def startup_toggle(self, widget):
|
def startup_toggle(self, widget):
|
||||||
if widget.get_active() is True:
|
try:
|
||||||
if os.path.isfile(GUI.dot_desktop):
|
# Check if the toggle button is active
|
||||||
shutil.copy(GUI.dot_desktop, GUI.autostart)
|
if widget.get_active():
|
||||||
else:
|
# If active, copy the .desktop file to autostart location
|
||||||
if os.path.isfile(GUI.autostart):
|
if os.path.isfile(GUI.dot_desktop):
|
||||||
os.unlink(GUI.autostart)
|
shutil.copy(GUI.dot_desktop, GUI.autostart)
|
||||||
self.save_settings(widget.get_active())
|
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):
|
def save_settings(self, state):
|
||||||
with open(GUI.Settings, "w") as f:
|
with open(GUI.Settings, "w") as f:
|
||||||
|
Reference in New Issue
Block a user