Make installation undependable from tweaks

Updated copyright years ("better late than never" ahh change)
This commit is contained in:
Vladyslav Hroshev
2024-09-01 21:21:46 +03:00
parent 4d2269664c
commit 7c7a474ad0
10 changed files with 141 additions and 39 deletions
+1
View File
@@ -14,4 +14,5 @@ extracted_gdm_folder = "theme"
# files definitions
gnome_shell_css = f"{temp_gnome_folder}/gnome-shell.css"
tweak_file = f"./{tweaks_folder}/*/tweak.py"
colors_json = "colors.json"
+3
View File
@@ -159,6 +159,9 @@ class GlobalTheme:
:param sat: color saturation
"""
if os.geteuid() != 0:
raise Exception("Root privileges required to install GDM theme")
if self.__is_installed():
print("Theme is installed. Reinstalling...")
self.gst += ".backup"
+1 -1
View File
@@ -47,7 +47,7 @@ class Theme:
("BUTTON-TEXT_SECONDARY", "TEXT-BLACK_SECONDARY"))
def __add__(self, other):
"""Z
"""
Add to main styles another styles
:param other: styles to add
:return: new Theme object
+58
View File
@@ -0,0 +1,58 @@
import glob
import os
from scripts import config
import importlib.util
class TweaksManager:
"""
Tweak manager class to load and apply tweaks from the tweak files in the tweaks folder
(I think this class manages the tweaks)
"""
def __init__(self):
self.tweak_files = glob.glob(config.tweak_file)
@staticmethod
def load_tweak(tweak_file):
"""
Load the tweak module :return:
"""
is_executable = os.access(tweak_file, os.X_OK)
if not is_executable:
os.chmod(tweak_file, 0o755)
if os.access(tweak_file, os.X_OK):
spec = importlib.util.spec_from_file_location("tweak_module", tweak_file)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
return None
def define_arguments(self, parser):
"""
Define arguments for the tweaks
:param parser: ArgumentParser object
"""
for tweak_file in self.tweak_files:
tweak_module = self.load_tweak(tweak_file)
if tweak_module:
tweak_module.define_arguments(parser)
def apply_tweaks(self, args, theme, colors):
"""
Apply the tweaks
:param args: parsed arguments
:param theme: Theme object
:param colors: colors.json object
"""
for tweak_file in self.tweak_files:
tweak_module = self.load_tweak(tweak_file)
if tweak_module:
tweak_module.apply_tweak(args, theme, colors)