Skip to content

tray: order unconfigured items alphabetically, log item keys - #5297

Open
Carltoffel wants to merge 1 commit into
Alexays:masterfrom
Carltoffel:feature/tray-deterministic-order
Open

tray: order unconfigured items alphabetically, log item keys#5297
Carltoffel wants to merge 1 commit into
Alexays:masterfrom
Carltoffel:feature/tray-deterministic-order

Conversation

@Carltoffel

Copy link
Copy Markdown

Closes #4162.

Two gaps around tray ordering.

Ordering is only deterministic for configured items

orders pins the items you name. Everything else keeps the order in which the
applications happened to win the race to register on D-Bus, which is what #4162
is about — it differs between restarts, and as noted in that thread it differs
between the outputs of a single bar, so two monitors show two different trays.

To get a stable layout today you have to enumerate every item with an explicit
integer, including the ones you have no opinion about.

This sorts items sharing an order value by their key instead of leaving them at
insertion order. Items with no entry in orders all sit at 0, so they end up
alphabetical between the negative and the positive ones, and the default layout
is stable without any configuration at all.

The key an item is addressed by is invisible

orders and icons address an item by its SNI Id, or by its lowercased
tooltip for Chrome-based apps whose Id is not unique. Neither appears anywhere
in the UI, and the man page only said "name of item" — so configuring Rocket.Chat
means guessing Rocket.Chat_status_icon_1.

Log it once per key at info level:

[info] tray: item key 'nm-applet'
[info] tray: item key 'Rocket.Chat_status_icon_1'

Deduplicated on purpose: every bar runs its own Host with its own Item
objects, so an unguarded line fires once per output, and again on every Id
property update.

The man page gets a section documenting both the keys and the default order.

Notes

Item::sort_key holds the key separately from the icon id. The two are only
incidentally the same string — the icon id is what gets looked up in icons,
and tying the sort order to it would mean an icon config change silently
reshuffles the tray.

No new config options.

Testing

Against a live tray with six items (gammastep, nm-applet, Telegram, and three
Electron apps):

  • no orders at all → Claude_status_icon_1, gammastep, nm-applet,
    Rocket.Chat_status_icon_1, TelegramDesktop, vesktop_status_icon_1
  • {"gammastep": -5, "nm-applet": 10, "Claude_status_icon_1": 20} → gammastep,
    then the alphabetical remainder, then nm-applet, then Claude
  • each key logged exactly once on a two-output setup (twice before this change)

Two gaps around tray ordering, both from Alexays#4162.

Ordering is only deterministic for items that appear in "orders".
Everything else keeps the order in which the applications happened to
win the race to register on D-Bus, which differs between restarts and
even between the outputs of a single bar. To get a stable tray today you
have to enumerate every item with an explicit integer, including the
ones you do not care about.

Sort items sharing an order value by their key instead of leaving them
at insertion order. Items with no entry in "orders" all sit at 0, so
they end up alphabetical between the negative and the positive ones,
and the default layout is stable without any configuration.

The second gap is that the key an item is addressed by is invisible.
It is the SNI Id, or the lowercased tooltip for Chrome-based apps whose
Id is not unique -- so the key for Rocket.Chat is
"Rocket.Chat_status_icon_1", which nobody guesses, and there is nowhere
to look it up. Log it once per key at info level, and document both the
keys and the default order in the man page.

Item::sort_key holds the key, deduplicated from the icon id because the
two are only incidentally the same string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Consistent ordering of tray icons

1 participant