Vladimir-csp / uwsm

Universal Wayland Session Manager
MIT License
149 stars 6 forks source link

`app` subcommand cannot launch stock KDE applications #26

Closed svvac closed 3 months ago

svvac commented 3 months ago

The .validate() method of xdg.DesktopEntry.DesktopEntry performs (very) strict validation of XDG desktop files.

Because of this, many stock KDE applications, such as Dolphin, cannot be started, because they contain localized keys using an invalid locale identifier x-test.

$ uwsm app org.kde.dolphin.desktop
Entry /usr/share/applications/org.kde.dolphin.desktop failed validation:
  err: Invalid key: Keywords[x-test]
  err: Invalid key: Name[x-test]
  err: Invalid key: GenericName[x-test]
$ grep x-test /usr/share/applications/org.kde.dolphin.desktop
Name[x-test]=xxDolphinxx
GenericName[x-test]=xxFile Managerxx
Keywords[x-test]=xxfilesxx;xxfile managementxx;xxfile browsingxx;xxsambaxx;xxnetwork sharesxx;xxExplorerxx;xxFinderxx;
svvac commented 3 months ago

The following patch works around the issue:

diff --git i/uwsm/main.py w/uwsm/main.py
index 85533a4..c9c1dd1 100644
--- i/uwsm/main.py
+++ w/uwsm/main.py
@@ -146,6 +146,9 @@ class Val:
     sh_varname = re.compile(
         r"\A([a-zA-Z_][a-zA-Z0-9_]+|[a-zA-Z][a-zA-Z0-9_]*)\Z", re.MULTILINE
     )
+    invalid_locale_key_error = re.compile(
+        r"^Invalid key: \w+\[.+\]$"
+    )

 def dedent(data: str) -> str:
@@ -481,6 +484,8 @@ def check_entry_basic(entry, entry_action=None):
             "Invalid key: TargetEnvironment",
         ]:
             continue
+        if Val.invalid_locale_key_error.match(error):
+            continue
         errors.add(error)
     if errors:
         raise RuntimeError(
Vladimir-csp commented 3 months ago

Thanks! d2003e9c