|
4 | 4 | from kde_material_you_colors import settings |
5 | 5 | from kde_material_you_colors.utils import math_utils |
6 | 6 | from kde_material_you_colors.utils import string_utils |
| 7 | +from kde_material_you_colors.utils import color_utils |
7 | 8 | from kde_material_you_colors.schemeconfigs import ThemeConfig |
8 | 9 |
|
9 | 10 |
|
@@ -272,3 +273,53 @@ def kwin_rule_darker_titlebar(light, darker_window_list): |
272 | 273 |
|
273 | 274 | with open(settings.KWIN_RULES_RC, "w") as configfile: |
274 | 275 | kwin_rules.write(configfile, space_around_delimiters=False) |
| 276 | + |
| 277 | + |
| 278 | +def kde_rounded_corners_effect_outline_color(schemes: ThemeConfig, light=None): |
| 279 | + if light: |
| 280 | + outline = string_utils.tup2str( |
| 281 | + color_utils.hex2rgb( |
| 282 | + schemes.get_material_schemes()["schemes"]["light"]["primaryFixed"] |
| 283 | + ) |
| 284 | + ) |
| 285 | + outline_inactive = string_utils.tup2str( |
| 286 | + color_utils.hex2rgb( |
| 287 | + schemes.get_material_schemes()["schemes"]["light"]["surfaceDim"] |
| 288 | + ) |
| 289 | + ) |
| 290 | + else: |
| 291 | + outline = string_utils.tup2str( |
| 292 | + color_utils.hex2rgb( |
| 293 | + schemes.get_material_schemes()["schemes"]["dark"]["primaryFixed"] |
| 294 | + ) |
| 295 | + ) |
| 296 | + outline_inactive = string_utils.tup2str( |
| 297 | + color_utils.hex2rgb( |
| 298 | + schemes.get_material_schemes()["schemes"]["dark"]["surfaceBright"] |
| 299 | + ) |
| 300 | + ) |
| 301 | + |
| 302 | + kwinrc = configparser.ConfigParser() |
| 303 | + # preserve case |
| 304 | + kwinrc.optionxform = str |
| 305 | + if os.path.exists(settings.KWIN_RC): |
| 306 | + try: |
| 307 | + kwinrc.read(settings.KWIN_RC) |
| 308 | + if "Round-Corners" not in kwinrc: |
| 309 | + kwinrc.add_section("Round-Corners") |
| 310 | + kwinrc["Round-Corners"]["OutlineColor"] = outline |
| 311 | + kwinrc["Round-Corners"]["InactiveOutlineColor"] = outline_inactive |
| 312 | + kwinrc["Round-Corners"]["ActiveOutlineAlpha"] = "255" |
| 313 | + kwinrc["Round-Corners"]["InactiveOutlineAlpha"] = "255" |
| 314 | + |
| 315 | + logging.info( |
| 316 | + "Applying KDE Rounded Corners desktop effect window outline color" |
| 317 | + ) |
| 318 | + with open(settings.KWIN_RC, "w", encoding="utf-8") as configfile: |
| 319 | + kwinrc.write(configfile, space_around_delimiters=False) |
| 320 | + except Exception as e: |
| 321 | + logging.error( |
| 322 | + f"Error writing KDE Rounded Corners desktop effect window outline color:\n{e}" |
| 323 | + ) |
| 324 | + else: |
| 325 | + logging.warning(f"KWin config '{settings.KWIN_RC}' not found, skipping") |
0 commit comments