Skip to content

Commit 006d5ef

Browse files
committed
fix: ensure sections exist in klassy configuration
refs: #267
1 parent 02617bd commit 006d5ef

1 file changed

Lines changed: 36 additions & 39 deletions

File tree

src/kde_material_you_colors/utils/titlebar_utils.py

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def titlebar_opacity(opacity_light, opacity_dark, light):
107107
if os.path.exists(settings.KLASSY_RC):
108108
try:
109109
conf_file.read(settings.KLASSY_RC)
110+
if "TitleBarOpacity" not in conf_file:
111+
conf_file.add_section("TitleBarOpacity")
110112
conf_file["TitleBarOpacity"]["ActiveTitleBarOpacity"] = str(
111113
int(opacity)
112114
)
@@ -144,50 +146,45 @@ def klassy_windeco_outline_color(schemes: ThemeConfig, light=None):
144146
if os.path.exists(settings.KLASSY_RC):
145147
try:
146148
klassyrc.read(settings.KLASSY_RC)
147-
if "WindowOutlineStyle" in klassyrc:
148-
klassyrc["WindowOutlineStyle"][
149-
"ThinWindowOutlineStyleActive"
150-
] = "WindowOutlineCustomColor"
151-
klassyrc["WindowOutlineStyle"][
152-
"ThinWindowOutlineStyleInactive"
153-
] = "WindowOutlineCustomColor"
149+
if "WindowOutlineStyle" not in klassyrc:
150+
klassyrc.add_section("WindowOutlineStyle")
151+
klassyrc["WindowOutlineStyle"][
152+
"ThinWindowOutlineStyleActive"
153+
] = "WindowOutlineCustomColor"
154+
klassyrc["WindowOutlineStyle"][
155+
"ThinWindowOutlineStyleInactive"
156+
] = "WindowOutlineCustomColor"
154157

155-
klassyrc["WindowOutlineStyle"][
156-
"ThinWindowOutlineCustomColorActive"
157-
] = outline
158-
klassyrc["WindowOutlineStyle"][
159-
"ThinWindowOutlineCustomColorInactive"
160-
] = outline_inactive
158+
klassyrc["WindowOutlineStyle"][
159+
"ThinWindowOutlineCustomColorActive"
160+
] = outline
161+
klassyrc["WindowOutlineStyle"][
162+
"ThinWindowOutlineCustomColorInactive"
163+
] = outline_inactive
161164

162-
klassyrc["WindowOutlineStyle"][
163-
"WindowOutlineCustomColorOpacityActive"
164-
] = "100"
165-
klassyrc["WindowOutlineStyle"][
166-
"WindowOutlineCustomColorOpacityInactive"
167-
] = "100"
165+
klassyrc["WindowOutlineStyle"][
166+
"WindowOutlineCustomColorOpacityActive"
167+
] = "100"
168+
klassyrc["WindowOutlineStyle"][
169+
"WindowOutlineCustomColorOpacityInactive"
170+
] = "100"
168171

169-
# klassy 6.5
172+
# klassy 6.5
170173

171-
klassyrc["WindowOutlineStyle"][
172-
"WindowOutlineStyleActive"
173-
] = "WindowOutlineCustomColor"
174-
klassyrc["WindowOutlineStyle"][
175-
"WindowOutlineStyleInactive"
176-
] = "WindowOutlineCustomColor"
177-
klassyrc["WindowOutlineStyle"][
178-
"WindowOutlineCustomColorActive"
179-
] = outline
180-
klassyrc["WindowOutlineStyle"][
181-
"WindowOutlineCustomColorInactive"
182-
] = outline_inactive
174+
klassyrc["WindowOutlineStyle"][
175+
"WindowOutlineStyleActive"
176+
] = "WindowOutlineCustomColor"
177+
klassyrc["WindowOutlineStyle"][
178+
"WindowOutlineStyleInactive"
179+
] = "WindowOutlineCustomColor"
180+
klassyrc["WindowOutlineStyle"]["WindowOutlineCustomColorActive"] = outline
181+
klassyrc["WindowOutlineStyle"][
182+
"WindowOutlineCustomColorInactive"
183+
] = outline_inactive
183184

184-
reload = True
185-
else:
186-
reload = False
187-
if reload:
188-
logging.info("Applying Klassy outline color")
189-
with open(settings.KLASSY_RC, "w", encoding="utf-8") as configfile:
190-
klassyrc.write(configfile, space_around_delimiters=False)
185+
logging.info("Applying Klassy outline color")
186+
with open(settings.KLASSY_RC, "w", encoding="utf-8") as configfile:
187+
klassyrc.write(configfile, space_around_delimiters=False)
191188
except Exception as e:
192189
logging.error(f"Error writing Klassy outline color:\n{e}")
193190
else:

0 commit comments

Comments
 (0)