Skip to content

Commit c5d83f3

Browse files
authored
cs_keyboard.py: Skip invalid bindings (#12396)
It is possible to remove Spices manually by removing the associated directories rather than using the appropriate module. This results in the bindings still being stored internally. When loading the Keyboard module and this scenario has occurred, it results in a failure due to the matching files having been removed. We leave the mappings internally so that if the matching Spice is reinstalled, the previous settings will be retained.
1 parent 90fe77c commit c5d83f3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

files/usr/share/cinnamon/cinnamon-settings/modules/cs_keyboard.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,12 @@ def on_module_selected(self):
535535
home = os.path.expanduser("~")
536536
gettext.bindtextdomain(name, f"{home}/.local/share/locale")
537537
gettext.textdomain(name)
538-
with open(f"{home}/.local/share/cinnamon/{_type}/{name}/metadata.json", encoding="utf-8") as metadata:
539-
json_data = json.load(metadata)
540-
category_label = gettext.gettext(_(json_data["name"]))
538+
try:
539+
with open(f"{home}/.local/share/cinnamon/{_type}/{name}/metadata.json", encoding="utf-8") as metadata:
540+
json_data = json.load(metadata)
541+
category_label = gettext.gettext(_(json_data["name"]))
542+
except FileNotFoundError:
543+
continue
541544
if not _id:
542545
cat_label = category_label if category_label else name
543546
CATEGORIES.append([cat_label, name, "spices", None, properties])

0 commit comments

Comments
 (0)