From ab6fa15a1a8cfd0f795f2a30ff9f37f22148e025 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Thu, 19 Jan 2023 16:13:03 +0100 Subject: [PATCH] misc: Hide desktop entry, prevent autostart on success --- vanilla_first_setup/utils/processor.py | 23 +++++++++++++++++++++-- vanilla_first_setup/window.py | 7 ++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/vanilla_first_setup/utils/processor.py b/vanilla_first_setup/utils/processor.py index cfbaed6..b2f763a 100644 --- a/vanilla_first_setup/utils/processor.py +++ b/vanilla_first_setup/utils/processor.py @@ -141,8 +141,6 @@ class Processor: autostart_file = os.path.expanduser( "~/.config/autostart/org.vanillaos.FirstSetup.desktop") - if os.path.exists(autostart_file): - os.remove(autostart_file) # run the outRun commands if out_run: @@ -150,3 +148,24 @@ class Processor: subprocess.run(out_run, shell=True) return True, "" + + @staticmethod + def hide_first_setup(): + desktop_file = os.path.expanduser( + "~/.local/share/applications/org.vanillaos.FirstSetup.desktop") + autostart_file = os.path.expanduser( + "~/.config/autostart/org.vanillaos.FirstSetup.desktop") + + if os.path.exists(autostart_file): + os.remove(autostart_file) + + with open(desktop_file, "w") as f: + f.write("[Desktop Entry]\n") + f.write("Name=FirstSetup\n") + f.write("Comment=FirstSetup\n") + f.write("Exec=vanilla-first-setup\n") + f.write("Terminal=false\n") + f.write("Type=Application\n") + f.write("NoDisplay=true\n") + f.flush() + f.close() diff --git a/vanilla_first_setup/window.py b/vanilla_first_setup/window.py index 8f4f6c0..df91c62 100644 --- a/vanilla_first_setup/window.py +++ b/vanilla_first_setup/window.py @@ -119,13 +119,18 @@ class VanillaWindow(Adw.ApplicationWindow): commands = Parser.parse(finals) # process the commands - return Processor.run( + res = Processor.run( self.recipe.get("log_file", "/tmp/vanilla_first_setup.log"), self.recipe.get("pre_run", []), self.recipe.get("post_run"), commands ) + if res: + Processor.hide_first_setup() + + return res + def on_done(result, *args): if self.__init_mode == 0: self.__view_done.set_result(result)