Files
lhns--steam-frame-nix/modules/launcher-menu/order/patch.js
T
Pierre Kisters 24d6504f30 Add steam-ui-patches (generic Steam UI runtime patches) and launcher-menu
steamFrame.uiPatches.patches registers JS patches that the
steam-ui-patches user service keeps injected into Steam's (or SteamVR's)
web UI over the local CEF DevTools ports and reverts when it stops.

steamFrame.launcherMenu uses it for the VR "+" menu: sort = true sorts
the programs by name; pinDesktop = "top" / "bottom" pins Desktop above or
below the scrolling list.
2026-09-27 19:36:12 +02:00

28 lines
1.3 KiB
JavaScript

// launcher-menu order: sorts the VR dashboard's "+" menu (non-Steam programs)
// alphabetically (case-insensitive), Desktop included.
// Steam renders SteamClient.Apps.ScanForInstalledNonSteamApps() in the order
// it returns (GLib hash-table order, i.e. random-ish); its hook looks the
// function up at call time, so wrapping it here in SharedJSContext is enough.
// The original is kept as __sfuiOrig (unpatch.js restores it). Idempotent;
// bump VERSION when changing the wrapper.
(() => {
const VERSION = 3;
const NAME = 'launcher-menu-order';
const Apps = window.SteamClient?.Apps;
const cur = Apps?.ScanForInstalledNonSteamApps;
if (typeof cur !== 'function') return 'SteamClient.Apps.ScanForInstalledNonSteamApps missing';
if (cur.__sfuiPatch === NAME && cur.__sfuiVersion === VERSION) return 'unchanged';
const orig = cur.__sfuiPatch === NAME ? cur.__sfuiOrig : cur;
const name = (a) => String(a?.strAppName ?? '');
const sort = (list) => Array.isArray(list)
? [...list].sort((a, b) => name(a).localeCompare(name(b), undefined, { sensitivity: 'base' }))
: list;
const f = function ScanForInstalledNonSteamApps(...args) {
return Promise.resolve(orig.apply(this, args)).then(sort);
};
f.__sfuiPatch = NAME; f.__sfuiVersion = VERSION; f.__sfuiOrig = orig;
Apps.ScanForInstalledNonSteamApps = f;
return 'patched';
})()