From 732814378487b22a9d0b52a30e8e03df4ec71ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Sun, 14 Dec 2025 07:40:12 +0100 Subject: [PATCH] Use locale-aware sort for menu entries This fixes the problem that entries started with non-English characters are placed at the end of the list. --- src/xdgmenumaker | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/xdgmenumaker b/src/xdgmenumaker index a11af78..5e55378 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -6,6 +6,7 @@ import os import sys import getopt import fnmatch +import locale import xdg.DesktopEntry as dentry import xdg.Exceptions as exc import xdg.BaseDirectory as bd @@ -431,7 +432,10 @@ def sortedcategories(applist): categories = [] for e in applist: categories.append(e.category) - categories = sorted(set(categories)) + categories = sorted( + set(categories), + key=lambda category: locale.strxfrm(category.decode()) + ) return categories @@ -485,7 +489,13 @@ def menu(ico_paths=True): except exc.ParsingError: pass - sortedapplist = sorted(applist, key=attrgetter('category', 'app.name')) + sortedapplist = sorted( + applist, + key=lambda entry: ( + locale.strxfrm(entry.category.decode()), + locale.strxfrm(entry.app.name.decode()), + ) + ) menu = [] for c in sortedcategories(applist): @@ -925,4 +935,5 @@ def openbox(): if __name__ == "__main__": + locale.setlocale(locale.LC_COLLATE, '') main(sys.argv[1:])