mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-25 20:56:39 -07:00
Make installation undependable from tweaks
Updated copyright years ("better late than never" ahh change)
This commit is contained in:
58
install.py
58
install.py
@@ -1,5 +1,5 @@
|
|||||||
# This file installs Marble shell theme for GNOME DE
|
# This file installs Marble shell theme for GNOME DE
|
||||||
# Copyright (C) 2023 Vladyslav Hroshev
|
# Copyright (C) 2023-2024 Vladyslav Hroshev
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,10 +21,9 @@ import shutil
|
|||||||
import textwrap # example text in argparse
|
import textwrap # example text in argparse
|
||||||
|
|
||||||
from scripts import config # folder and files definitions
|
from scripts import config # folder and files definitions
|
||||||
|
from scripts.tweaks_manager import TweaksManager # load tweaks from files
|
||||||
|
|
||||||
from scripts.utils import (
|
from scripts.utils import remove_files # delete already installed Marble theme
|
||||||
remove_files, # delete already installed Marble theme
|
|
||||||
hex_to_rgba) # convert HEX to RGBA
|
|
||||||
|
|
||||||
from scripts.theme import Theme
|
from scripts.theme import Theme
|
||||||
from scripts.gdm import GlobalTheme
|
from scripts.gdm import GlobalTheme
|
||||||
@@ -80,44 +79,44 @@ def parse_args():
|
|||||||
gdm_theming.add_argument('--gdm', action='store_true', help='install GDM theme. \
|
gdm_theming.add_argument('--gdm', action='store_true', help='install GDM theme. \
|
||||||
Requires root privileges. You must specify a specific color.')
|
Requires root privileges. You must specify a specific color.')
|
||||||
|
|
||||||
panel_args = parser.add_argument_group('Panel tweaks')
|
# Dynamically load arguments from each tweak script
|
||||||
panel_args.add_argument('-Pds', '--panel_default_size', action='store_true', help='set default panel size')
|
tweaks_manager = TweaksManager()
|
||||||
panel_args.add_argument('-Pnp', '--panel_no_pill', action='store_true', help='remove panel button background')
|
tweaks_manager.define_arguments(parser)
|
||||||
panel_args.add_argument('-Ptc', '--panel_text_color', type=str, nargs='?', help='custom panel HEX(A) text color')
|
|
||||||
|
|
||||||
overview_args = parser.add_argument_group('Overview tweaks')
|
|
||||||
overview_args.add_argument('--launchpad', action='store_true', help='change Show Apps icon to MacOS Launchpad icon')
|
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def apply_tweaks(args, theme):
|
def apply_tweaks(args, theme, colors):
|
||||||
"""
|
"""
|
||||||
Apply theme tweaks
|
Apply theme tweaks
|
||||||
:param args: parsed arguments
|
:param args: parsed arguments
|
||||||
:param theme: Theme object
|
:param theme: Theme object
|
||||||
|
:param colors: colors from colors.json
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if args.panel_default_size:
|
tweaks_manager = TweaksManager()
|
||||||
with open(f"{config.tweaks_folder}/panel/def-size.css", "r") as f:
|
tweaks_manager.apply_tweaks(args, theme, colors)
|
||||||
theme += f.read()
|
|
||||||
|
|
||||||
if args.panel_no_pill:
|
# if args.panel_default_size:
|
||||||
with open(f"{config.tweaks_folder}/panel/no-pill.css", "r") as f:
|
# with open(f"{config.tweaks_folder}/panel/def-size.css", "r") as f:
|
||||||
theme += f.read()
|
# theme += f.read()
|
||||||
|
|
||||||
if args.panel_text_color:
|
# if args.panel_no_pill:
|
||||||
theme += ".panel-button,\
|
# with open(f"{config.tweaks_folder}/panel/no-pill.css", "r") as f:
|
||||||
.clock,\
|
# theme += f.read()
|
||||||
.clock-display StIcon {\
|
|
||||||
color: rgba(" + ', '.join(map(str, hex_to_rgba(args.panel_text_color))) + ");\
|
|
||||||
}"
|
|
||||||
|
|
||||||
if args.launchpad:
|
# if args.panel_text_color:
|
||||||
with open(f"{config.tweaks_folder}/launchpad/launchpad.css", "r") as f:
|
# theme += ".panel-button,\
|
||||||
theme += f.read()
|
# .clock,\
|
||||||
|
# .clock-display StIcon {\
|
||||||
|
# color: rgba(" + ', '.join(map(str, hex_to_rgba(args.panel_text_color))) + ");\
|
||||||
|
# }"
|
||||||
|
|
||||||
theme *= f"{config.tweaks_folder}/launchpad/launchpad.png"
|
# if args.overview:
|
||||||
|
# with open(f"{config.tweaks_folder}/overview/overview.css", "r") as f:
|
||||||
|
# theme += f.read()
|
||||||
|
|
||||||
|
# theme *= f"{config.tweaks_folder}/overview/overview.png"
|
||||||
|
|
||||||
|
|
||||||
def install_theme(theme, hue, theme_name, sat, gdm=False):
|
def install_theme(theme, hue, theme_name, sat, gdm=False):
|
||||||
@@ -214,7 +213,7 @@ def local_theme(args, colors):
|
|||||||
config.themes_folder, config.temp_folder,
|
config.themes_folder, config.temp_folder,
|
||||||
mode=args.mode, is_filled=args.filled)
|
mode=args.mode, is_filled=args.filled)
|
||||||
|
|
||||||
apply_tweaks(args, gnome_shell_theme)
|
apply_tweaks(args, gnome_shell_theme, colors)
|
||||||
apply_colors(args, gnome_shell_theme, colors)
|
apply_colors(args, gnome_shell_theme, colors)
|
||||||
|
|
||||||
|
|
||||||
@@ -226,7 +225,6 @@ def main():
|
|||||||
if args.gdm:
|
if args.gdm:
|
||||||
global_theme(args, colors)
|
global_theme(args, colors)
|
||||||
|
|
||||||
# if not GDM theme
|
|
||||||
else:
|
else:
|
||||||
local_theme(args, colors)
|
local_theme(args, colors)
|
||||||
|
|
||||||
|
@@ -14,4 +14,5 @@ extracted_gdm_folder = "theme"
|
|||||||
|
|
||||||
# files definitions
|
# files definitions
|
||||||
gnome_shell_css = f"{temp_gnome_folder}/gnome-shell.css"
|
gnome_shell_css = f"{temp_gnome_folder}/gnome-shell.css"
|
||||||
|
tweak_file = f"./{tweaks_folder}/*/tweak.py"
|
||||||
colors_json = "colors.json"
|
colors_json = "colors.json"
|
||||||
|
@@ -159,6 +159,9 @@ class GlobalTheme:
|
|||||||
:param sat: color saturation
|
:param sat: color saturation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
raise Exception("Root privileges required to install GDM theme")
|
||||||
|
|
||||||
if self.__is_installed():
|
if self.__is_installed():
|
||||||
print("Theme is installed. Reinstalling...")
|
print("Theme is installed. Reinstalling...")
|
||||||
self.gst += ".backup"
|
self.gst += ".backup"
|
||||||
|
@@ -47,7 +47,7 @@ class Theme:
|
|||||||
("BUTTON-TEXT_SECONDARY", "TEXT-BLACK_SECONDARY"))
|
("BUTTON-TEXT_SECONDARY", "TEXT-BLACK_SECONDARY"))
|
||||||
|
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
"""Z
|
"""
|
||||||
Add to main styles another styles
|
Add to main styles another styles
|
||||||
:param other: styles to add
|
:param other: styles to add
|
||||||
:return: new Theme object
|
:return: new Theme object
|
||||||
|
58
scripts/tweaks_manager.py
Normal file
58
scripts/tweaks_manager.py
Normal 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)
|
@@ -1,7 +0,0 @@
|
|||||||
/* Change Show Apps icon to MacOS Launchpad icon */
|
|
||||||
|
|
||||||
.show-apps .show-apps-icon {
|
|
||||||
color: transparent;
|
|
||||||
background-image: url("launchpad.png");
|
|
||||||
background-size: contain;
|
|
||||||
}
|
|
7
tweaks/overview/launchpad/launchpad.css
Normal file
7
tweaks/overview/launchpad/launchpad.css
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/* Change Show Apps icon to macOS Launchpad icon */
|
||||||
|
|
||||||
|
.show-apps .show-apps-icon {
|
||||||
|
color: transparent;
|
||||||
|
background-image: url("./launchpad.png");
|
||||||
|
background-size: contain;
|
||||||
|
}
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
15
tweaks/overview/tweak.py
Executable file
15
tweaks/overview/tweak.py
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
from scripts import config
|
||||||
|
overview_folder = f"{config.tweaks_folder}/overview"
|
||||||
|
|
||||||
|
|
||||||
|
def define_arguments(parser):
|
||||||
|
overview_args = parser.add_argument_group('Overview tweaks')
|
||||||
|
overview_args.add_argument('--launchpad', action='store_true', help='change Show Apps icon to macOS Launchpad icon')
|
||||||
|
|
||||||
|
|
||||||
|
def apply_tweak(args, theme, colors):
|
||||||
|
if args.launchpad:
|
||||||
|
with open(f"{overview_folder}/launchpad/launchpad.css", "r") as f:
|
||||||
|
theme += f.read()
|
||||||
|
|
||||||
|
theme *= f"{overview_folder}/launchpad/launchpad.png"
|
27
tweaks/panel/tweak.py
Executable file
27
tweaks/panel/tweak.py
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
from scripts import config
|
||||||
|
from scripts.utils import hex_to_rgba
|
||||||
|
panel_folder = f"{config.tweaks_folder}/panel"
|
||||||
|
|
||||||
|
|
||||||
|
def define_arguments(parser):
|
||||||
|
panel_args = parser.add_argument_group('Panel tweaks')
|
||||||
|
panel_args.add_argument('-Pds', '--panel_default_size', action='store_true', help='set default panel size')
|
||||||
|
panel_args.add_argument('-Pnp', '--panel_no_pill', action='store_true', help='remove panel button background')
|
||||||
|
panel_args.add_argument('-Ptc', '--panel_text_color', type=str, nargs='?', help='custom panel HEX(A) text color')
|
||||||
|
|
||||||
|
|
||||||
|
def apply_tweak(args, theme, colors):
|
||||||
|
if args.panel_default_size:
|
||||||
|
with open(f"{panel_folder}/def-size.css", "r") as f:
|
||||||
|
theme += f.read()
|
||||||
|
|
||||||
|
if args.panel_no_pill:
|
||||||
|
with open(f"{panel_folder}/no-pill.css", "r") as f:
|
||||||
|
theme += f.read()
|
||||||
|
|
||||||
|
if args.panel_text_color:
|
||||||
|
theme += ".panel-button,\
|
||||||
|
.clock,\
|
||||||
|
.clock-display StIcon {\
|
||||||
|
color: rgba(" + ', '.join(map(str, hex_to_rgba(args.panel_text_color))) + ");\
|
||||||
|
}"
|
Reference in New Issue
Block a user