Bind SUPER + CTRL + a number to the bar's right panels (#6702)

The letters name a panel; the numbers count them. One is the leftmost
panel in the right section, so the number matches the icon a user would
point at: a widget with no panel of its own is passed over, and so is one
that is hiding itself.

Counting rather than naming means the hotkeys follow the bar. Rearranging
the section, or adding a widget to it, renumbers the panels with no
binding to rewrite.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-08-11 13:03:20 +02:00
committed by GitHub
co-authored by Claude Opus 5
parent efe805387e
commit 5edc3497fa
5 changed files with 72 additions and 0 deletions
+15
View File
@@ -417,6 +417,21 @@ Item {
return slots
}
// The Nth panel in a bar region, counted the way the bar reads: layout order,
// and only the panels actually on screen. A widget with no panel (the tray)
// and one that is hiding itself are passed over, so the number lands on the
// Nth panel icon the user can see rather than the Nth layout entry.
// One-based, because it exists for hotkeys; anything else lands on no slot.
//
// Counting any bar surface is enough: every monitor lays its bar out from the
// one layout, and summoning the id routes through pickPanelSlot, which opens
// the focused monitor's copy whichever surface was counted.
function panelWidgetIdAt(region, index) {
var slots = panelNavigationSlots(String(region || ""), null)
var slot = slots[Math.round(Number(index)) - 1]
return slot ? String(slot.moduleName || "") : ""
}
function switchPanelFrom(owner, direction) {
if (!owner) return false
+13
View File
@@ -1011,6 +1011,19 @@ ShellRoot {
shell.toggle(id, payloadJson)
}
// A bar section's panels answer to their position as well as their id, so a
// hotkey can mean "the third panel in the right section" and keep meaning
// it after the bar is rearranged. Returns the id it acted on, or "unknown"
// when the section holds no panel at that position.
function togglePanelAt(section: string, index: string): string {
var id = shell.bar && typeof shell.bar.panelWidgetIdAt === "function"
? shell.bar.panelWidgetIdAt(section, index)
: ""
if (!id) return "unknown"
shell.toggle(id, "{}")
return id
}
function call(id: string, method: string, arg: string): string {
return shell.callIfLoaded(id, method, arg)
}