Skip to content

Commit

Permalink
cs_themes: Blacklist Adwaita and HighContrast
Browse files Browse the repository at this point in the history
Adwaita looks awful since GNOME 46. It removed category icons
and a huge number of icons used by Cinnamon. This theme is
only meant to be used in GNOME and does not support Cinnamon.

HighContrast is very incomplete also. It's also a global setting
in A11Y.

GTK depends on Adwaita so these themes are always present. This commit
removes them from the theme selection since they make Cinnamon look
broken.

Note: This was done in Budgie in 2022 for the same reasons. It should
probably be done in all DEs really.
BuddiesOfBudgie/budgie-desktop@27b9447
  • Loading branch information
clefebvre committed Apr 28, 2024
1 parent 41bab97 commit 13b1ad1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 68 deletions.
104 changes: 58 additions & 46 deletions files/usr/share/cinnamon/cinnamon-settings/modules/cs_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
os.path.join(GLib.get_user_data_dir(), "themes")
] + [os.path.join(datadir, "themes") for datadir in GLib.get_system_data_dirs()]

THEMES_BLACKLIST = [
"gnome", # not meant to be used as a theme. Provides icons to inheriting themes.
"hicolor", # same
"adwaita", # incomplete outside of GNOME, doesn't support Cinnamon.
"highcontrast" # same. Also, available via a11y as a global setting.
]


class Style:
def __init__(self, json_obj):
Expand Down Expand Up @@ -104,6 +111,8 @@ def refresh_themes(self):

# Gtk themes -- Only shows themes that have a gtk-3.* variation
for (name, path) in walk_directories(THEME_FOLDERS, self.filter_func_gtk_dir, return_directories=True):
if name.lower() in THEMES_BLACKLIST:
continue
for theme in self.gtk_themes:
if name == theme[0]:
if path == THEME_FOLDERS[0]:
Expand All @@ -130,7 +139,7 @@ def refresh_themes(self):
walked = walk_directories(ICON_FOLDERS, lambda d: os.path.isdir(d), return_directories=True)
valid = []
for directory in walked:
if directory[0] in ("gnome", "hicolor"):
if directory[0].lower() in THEMES_BLACKLIST:
continue
path = os.path.join(directory[1], directory[0], "index.theme")
if os.path.exists(path):
Expand All @@ -148,6 +157,8 @@ def refresh_themes(self):

# Cursor themes
for (name, path) in walk_directories(ICON_FOLDERS, lambda d: os.path.isdir(d) and os.path.exists(os.path.join(d, "cursors")), return_directories=True):
if name.lower() in THEMES_BLACKLIST:
continue
for theme in self.cursor_themes:
if name == theme[0]:
if path == ICON_FOLDERS[0]:
Expand Down Expand Up @@ -403,51 +414,52 @@ def reset_look_ui(self):
self.active_variant = None

path = "/usr/share/cinnamon/styles.d"
for filename in sorted(os.listdir(path)):
if filename.endswith(".styles"):
try:
with open(os.path.join(path, filename)) as f:
json_text = json.loads(f.read())
for style_json in json_text["styles"]:
style = Style(style_json)
for mode_name in ["mixed", "dark", "light"]:
if mode_name in style_json:
mode = Mode(mode_name)
for variant_json in style_json[mode_name]:
variant = Variant(variant_json)
if self.is_variant_valid(variant):
# Add the variant to the mode
mode.variants.append(variant)
if mode.default_variant is None:
# Assign the first variant as default
mode.default_variant = variant
if "default" in variant_json and variant_json["default"] == "true":
# Override default if specified
mode.default_variant = variant
# Add the mode to the style (if not done already)
if not mode_name in style.modes:
style.modes[mode_name] = mode
# Set it as the default mode if there's no default mode
if style.default_mode is None:
style.default_mode = mode
# Set active variant variables if the variant is active
if self.is_variant_active(variant):
self.active_style= style
self.active_mode_name = mode_name
self.active_variant = variant
# Override the default mode if specified
if "default" in style_json:
default_name = style_json["default"]
if default_name in style.modes:
style.default_mode = style.modes[default_name]

if style.default_mode is None:
print ("No valid mode/variants found for style:", style.name)
else:
self.styles[style.name] = style
except Exception as e:
print(f"Failed to parse styles from {filename}.")
print(e)
if os.path.exists(path):
for filename in sorted(os.listdir(path)):
if filename.endswith(".styles"):
try:
with open(os.path.join(path, filename)) as f:
json_text = json.loads(f.read())
for style_json in json_text["styles"]:
style = Style(style_json)
for mode_name in ["mixed", "dark", "light"]:
if mode_name in style_json:
mode = Mode(mode_name)
for variant_json in style_json[mode_name]:
variant = Variant(variant_json)
if self.is_variant_valid(variant):
# Add the variant to the mode
mode.variants.append(variant)
if mode.default_variant is None:
# Assign the first variant as default
mode.default_variant = variant
if "default" in variant_json and variant_json["default"] == "true":
# Override default if specified
mode.default_variant = variant
# Add the mode to the style (if not done already)
if not mode_name in style.modes:
style.modes[mode_name] = mode
# Set it as the default mode if there's no default mode
if style.default_mode is None:
style.default_mode = mode
# Set active variant variables if the variant is active
if self.is_variant_active(variant):
self.active_style= style
self.active_mode_name = mode_name
self.active_variant = variant
# Override the default mode if specified
if "default" in style_json:
default_name = style_json["default"]
if default_name in style.modes:
style.default_mode = style.modes[default_name]

if style.default_mode is None:
print ("No valid mode/variants found for style:", style.name)
else:
self.styles[style.name] = style
except Exception as e:
print(f"Failed to parse styles from {filename}.")
print(e)

# Populate the style combo
for name in sorted(self.styles.keys()):
Expand Down
22 changes: 0 additions & 22 deletions files/usr/share/cinnamon/styles.d/00_cinnamon.styles

This file was deleted.

0 comments on commit 13b1ad1

Please sign in to comment.