Make installation undependable from tweaks
Updated copyright years ("better late than never" ahh change)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user