From 068207c949d246a4a1b8a2bd8408ca99247032c3 Mon Sep 17 00:00:00 2001 From: Vladyslav Hroshev Date: Sun, 10 Dec 2023 23:09:34 +0200 Subject: [PATCH] Add ability to remove GDM theme --- install.py | 6 ++++++ scripts/gdm.py | 27 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/install.py b/install.py index f9cd0e4..42a9ba4 100644 --- a/install.py +++ b/install.py @@ -102,6 +102,12 @@ def main(): config.global_gnome_shell_theme, config.gnome_shell_gresource, config.temp_folder, is_filled=args.filled) + if args.remove: + gdm_rm_status = gdm_theme.remove() + if gdm_rm_status == 0: + print("GDM theme removed successfully.") + return 0 + if args.red or args.pink or args.purple or args.blue or args.green or args.yellow or args.gray: for color in colors["colors"]: if getattr(args, color): diff --git a/scripts/gdm.py b/scripts/gdm.py index 81ea67a..50ccf3f 100644 --- a/scripts/gdm.py +++ b/scripts/gdm.py @@ -28,6 +28,7 @@ class GlobalTheme: self.backup_file = f"{self.destination_file}.backup" self.backup_trigger = "\n/* Marble theme */\n" # trigger to check if theme is installed self.extracted_theme = f"{self.temp_folder}/{config.extracted_gdm_folder}" + self.gst = f"{self.destination_folder}/{self.destination_file}" # use backup file if theme is installed os.makedirs(self.temp_folder, exist_ok=True) # create temp folder @@ -147,8 +148,6 @@ class GlobalTheme: :param sat: color saturation """ - # use backup file if theme is installed - self.gst = f"{self.destination_folder}/{self.destination_file}" if self.__is_installed(): print("Theme is installed. Reinstalling...") self.gst += ".backup" @@ -177,3 +176,27 @@ class GlobalTheme: f"{self.destination_folder}/{self.destination_file}") return 0 + + def remove(self): + """ + Remove installed theme + """ + + # use backup file if theme is installed + if self.__is_installed(): + print("Theme is installed. Removing...") + + if os.path.isfile(f"{self.destination_folder}/{self.backup_file}"): + subprocess.run(f"sudo mv {self.backup_file} {self.destination_file}", + shell=True, cwd=self.destination_folder) + + else: + print("Backup file not found. Try reinstalling gnome-shell package.") + return 1 + + else: + print("Theme is not installed. Nothing to remove.") + print("If theme is still installed globally, try reinstalling gnome-shell package.") + return 1 + + return 0