Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

fix: assert write permissions on gnome-shell copy #808

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions gradience/backend/theming/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re
import shutil
import os.path
import stat
import sass

from gi.repository import GObject, Gio, GLib
Expand Down Expand Up @@ -91,12 +92,22 @@ def __init__(self, shell_version=None):
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)
Expand Down