enkore / j4-dmenu-desktop

A fast desktop menu
GNU General Public License v3.0
673 stars 69 forks source link

Items/Apps given to dmenu are not sorted #44

Closed bebehei closed 9 years ago

bebehei commented 9 years ago

The Items printed from app-object are not sorted. In my item-list these are the first two items:

CMake
CaesarIA

This not a big problem at the beginning. But after typing your keywords and dmenu gives the following suggestions:

Firefox Developer
Firefox Nightly - Safe Mode
Firefox Nightly
Firefox

So if I type in dmenu the word fire and press Return, it will execute Firefox Developer. This behavior is crappy. To execute the program, which my search-term matches best (Firefox) is at the last position.

I propose to sort the App-list lexicographically.

Firefox
Firefox Developer
Firefox Nightly
Firefox Nightly - Safe Mode

Additionally, you can then use the tab-completion properly from the dmenu.

But anyway, your program is fucking fast. This bug is the only thing which hinders me to use it.

enkore commented 9 years ago

Can't reproduce - we use std::map which orders lexicographically already.

Maybe your locale is not set correctly?

bebehei commented 9 years ago

Sorry, I'm using an exotic combination of German/English mix. Metrics are in German Standards and Language is english. Here is my setup:

[bebe:~] % printenv | grep LC
LC_NUMERIC=de_DE.UTF-8
LC_MONETARY=de_DE.UTF-8
LC_TIME=de_DE.UTF-8
LC_CTYPE=en_US.utf8
[bebe:~] % printenv | grep LANG
LANG=en_US.utf8
GDM_LANG=en_US.utf8

I don't believe the locale matters directly.

When I execute the command j4-dmenu-desktop --dmenu='tee tmp | dmenu'. This is the head of tmp:

CMake
CaesarIA
Counter-Strike: Global Offensive
Counter-Strike: Source
Goat Simulator
OBEY
Portal 2
Robocraft
Team Fortress 2
Afternoon Stalker

This is completely unsorted. How can this be?

enkore commented 9 years ago

Turns out I am kind of dumb with my comment above. Yes, that map is ordered (of course), but I didn't remember that the key is the file name, not the application name. I just never noticed this, because on my system the first 20+ app files appear sorted correctly. Also it never shows in using it, unless you have two different Firefox'es :)

Oh, and to put the cherry on the cake: the apps should be now sorted correctly taking locale into account. So öäüß and friends should be at the right spots.

bebehei commented 9 years ago

:+1: This works. Thank you! Could you please tag a release, too?

enkore commented 9 years ago

Done.

Note: Some items are seemingly not sorted - it's the GenericNames. They're output directly after the Name, so they will appear out of place compared with a output that's completely sorted.