From 881c9ed48b43d46b5d8ca7737f7476bd39134bc7 Mon Sep 17 00:00:00 2001 From: cameron Date: Tue, 15 Aug 2023 23:41:51 -0500 Subject: [PATCH] fix: assert write permissions on gnome-shell copy --- gradience/backend/theming/shell.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gradience/backend/theming/shell.py b/gradience/backend/theming/shell.py index 3cd29a71..ca6c2e7e 100644 --- a/gradience/backend/theming/shell.py +++ b/gradience/backend/theming/shell.py @@ -20,6 +20,7 @@ import os import re import shutil import os.path +import stat import sass from gi.repository import GObject, Gio, GLib @@ -91,12 +92,22 @@ class ShellTheme: self.templates_dir = os.path.join(datadir, "gradience", "shell", "templates", str(self.version_target)) self.source_dir = os.path.join(GLib.get_home_dir(), ".cache", "gradience", "gradience-shell", str(self.version_target)) - if os.path.exists(self.source_dir): - shutil.rmtree(self.source_dir) - # Copy shell theme source directories to ~/.cache/gradience/gradience-shell - shutil.copytree(os.path.join(datadir, "gradience", "shell", - str(self.version_target)), self.source_dir, dirs_exist_ok=True + def copy_function(src, dst): + dst_dir = os.path.dirname(dst) + os.chmod(dst_dir, os.stat(dst_dir).st_mode | stat.S_IWRITE) + + if (os.path.exists(dst)): + os.remove(dst) + + shutil.copy2(src, dst) + os.chmod(dst, os.stat(dst).st_mode | stat.S_IWRITE) + + shutil.copytree( + os.path.join(datadir, "gradience", "shell", str(self.version_target)), + self.source_dir, + dirs_exist_ok=True, + copy_function=copy_function ) # TODO: Allow user to use different name than "gradience-shell" (also, with default name, we should append "-light" suffix when generated from light preset)