MCPcopy Create free account
hub / github.com/basecamp/omarchy / selectKeyboard

Function selectKeyboard

shell/plugins/bar/widgets/KeyboardLayoutModel.js:103–111  ·  view source on GitHub ↗
(typed, namedByEvent)

Source from the content-addressed store, hash-verified

101// names a keyboard too, but leaves every one of them on the same layout, so the
102// label reads the same whichever of them the name settles on.
103function selectKeyboard(typed, namedByEvent) {
104 var keyboards = typed || []
105
106 return keyboards.find(function (keyboard) {
107 return keyboard.name === namedByEvent
108 }) || keyboards.reduce(function (furthest, keyboard) {
109 return layoutIndex(keyboard) > layoutIndex(furthest) ? keyboard : furthest
110 }, keyboards[0])
111}
112
113function layoutIndex(keyboard) {
114 return (keyboard && keyboard.active_layout_index) || 0

Callers

nothing calls this directly

Calls 1

layoutIndexFunction · 0.85

Tested by

no test coverage detected