This commit is contained in:
ari committed 2026-10-16 15:18:18 -04:00
1 parent 10ffe765b0
commit d42e24be81
10 files changed
+350 -394

No files matched your search

+42 -32
View File
@@ -1,5 +1,4 @@
<img src="logo.jpg" width="200" />
<img src="logo.jpg" width="200" />
# Skygqts # Skygqts
@@ -12,8 +11,8 @@ It ships three apps:
- **app-carousel** — a full-screen launcher carousel. Apps sit in a row; the - **app-carousel** — a full-screen launcher carousel. Apps sit in a row; the
one in the middle is selected. Configure it with a JSON file. one in the middle is selected. Configure it with a JSON file.
- **workspace-manager** — a workspace overview. A carousel of workspace cards - **workspace-manager** — a workspace overview. A carousel of workspace cards
(with a live list of their windows), a bar for renaming the current (with a live list of their windows), a vim-style search for windows by
workspace, and a 3D "window loop" for picking a window. title and app, and a 3D "window loop" for picking a window.
- **workspace-badge** — a small box in each bottom corner of every - **workspace-badge** — a small box in each bottom corner of every
monitor showing the active workspace's name and color. Click one to rename monitor showing the active workspace's name and color. Click one to rename
the workspace or pick a color. the workspace or pick a color.
@@ -92,7 +91,7 @@ qs -n -p ./workspace-badge
| `skygqts workspace-manager toggle` | Toggles the workspace carousel (also closes it) | | `skygqts workspace-manager toggle` | Toggles the workspace carousel (also closes it) |
| `skygqts workspace-manager goto` | Opens the workspace carousel | | `skygqts workspace-manager goto` | Opens the workspace carousel |
| `skygqts workspace-manager windows` | Opens the window loop for the focused workspace | | `skygqts workspace-manager windows` | Opens the window loop for the focused workspace |
| `skygqts workspace-manager rename` | Opens the carousel with the name field focused | | `skygqts workspace-manager search` | Opens the carousel with the window search open |
| `skygqts workspace-badge` | Shows the workspace badge on every monitor | | `skygqts workspace-badge` | Shows the workspace badge on every monitor |
| `skygqts workspace-badge --daemon` | Same, but detached from the terminal | | `skygqts workspace-badge --daemon` | Same, but detached from the terminal |
| `skygqts workspace-badge edit` | Opens the badge editor on the focused monitor | | `skygqts workspace-badge edit` | Opens the badge editor on the focused monitor |
@@ -110,7 +109,7 @@ Then bind them in your compositor, e.g.:
# Hyprland # Hyprland
bind = SUPER, TAB, exec, skygqts workspace-manager toggle bind = SUPER, TAB, exec, skygqts workspace-manager toggle
bind = SUPER, G, exec, skygqts workspace-manager windows bind = SUPER, G, exec, skygqts workspace-manager windows
bind = SUPER, N, exec, skygqts workspace-manager rename bind = SUPER, SLASH, exec, skygqts workspace-manager search
``` ```
The same calls are available over Quickshell IPC if you prefer not to use the The same calls are available over Quickshell IPC if you prefer not to use the
@@ -120,7 +119,7 @@ CLI:
qs ipc -p ./workspace-manager call workspace toggle qs ipc -p ./workspace-manager call workspace toggle
qs ipc -p ./workspace-manager call workspace goTo qs ipc -p ./workspace-manager call workspace goTo
qs ipc -p ./workspace-manager call workspace openWindowSelection qs ipc -p ./workspace-manager call workspace openWindowSelection
qs ipc -p ./workspace-manager call workspace openWorkspaceRename qs ipc -p ./workspace-manager call workspace openSearch
qs ipc -p ./workspace-badge call badge edit qs ipc -p ./workspace-badge call badge edit
@@ -231,8 +230,8 @@ skygqts workspace-manager --config ~/.config/skygqts/workspace-manager.json
It detects your compositor from the environment (`niri` or `hyprland`) and It detects your compositor from the environment (`niri` or `hyprland`) and
shows one column of workspace cards per monitor, each card listing the shows one column of workspace cards per monitor, each card listing the
workspace's windows. From there you can focus a workspace, rename it, or open workspace's windows. From there you can focus a workspace, open a window
a window loop. loop, or search windows by title and app.
### Config ### Config
@@ -240,14 +239,15 @@ The config file is optional. Anything missing or malformed falls back to the
default below, and the file is watched for changes. See default below, and the file is watched for changes. See
`workspace-manager.example.json`. `workspace-manager.example.json`.
| Field | Type | Default | Meaning | | Field | Type | Default | Meaning |
| ------------------- | ------ | ----------------------------------------- | ------------------------------- | | ------------------- | ------ | ------------------------------------------------------ | ------------------------------ |
| `keys.rename` | string | `"Ctrl+N"` | Key that focuses the name field | | `keys.windows` | string | `"Tab"` | Key that opens the window loop |
| `keys.windows` | string | `"Tab"` | Key that opens the window loop | | `hints.show` | bool | `true` | Show the small key hints |
| `hints.show` | bool | `true` | Show the small key hints | | `hints.windows` | string | `"{key}: to see windows"` | Hint text |
| `hints.rename` | string | `"{key}: to switch here"` | Hint text | | `hints.exitWindows` | string | `"{key} or Esc: to exit window carousel"` | Hint text |
| `hints.windows` | string | `"{key}: to see windows"` | Hint text | | `hints.search` | string | `"/: to search windows, n / N: next / previous match"` | Hint text |
| `hints.exitWindows` | string | `"{key} or Esc: to exit window carousel"` | Hint text |
The search keys (`/`, `n`, `N`) are fixed, like in vim.
In any hint, `{key}` is replaced by the matching key. Keys are written as In any hint, `{key}` is replaced by the matching key. Keys are written as
modifiers plus one key, joined by `+`. Recognised modifiers are `Ctrl` modifiers plus one key, joined by `+`. Recognised modifiers are `Ctrl`
@@ -258,22 +258,31 @@ a digit, `F1`–`F12`, `Space`, or `Tab` (for example `Ctrl+N`, `Super+Space`).
**Carousel** **Carousel**
| Key | Action | | Key | Action |
| ------------------------------ | -------------------------------------------- | | ---------------------------- | -------------------------------------------- |
| Up / Down | Previous / next workspace on this monitor | | Up / Down | Previous / next workspace on this monitor |
| Left / Right | Previous / next monitor | | Left / Right | Previous / next monitor |
| Enter | Focus the selected workspace | | Enter | Focus the selected workspace |
| Escape | Close without switching | | Escape | Close without switching |
| `keys.rename` (default Ctrl+N) | Focus the name field | | `keys.windows` (default Tab) | Open the window loop |
| `keys.windows` (default Tab) | Open the window loop | | `/` | Search windows |
| Scroll | Vertical = workspaces, horizontal = monitors | | `n` / `N` | Next / previous match of the last search |
| Scroll | Vertical = workspaces, horizontal = monitors |
**Renaming** **Search**
| Key | Action | `/` opens a search bar, in the carousel or the window loop. As you type, the
| ------ | ---------------------- | view jumps to the first window after the current one whose title or app
| Enter | Apply the new name | (niri `app_id`, Hyprland `class`) contains the text, opening the window loop
| Escape | Leave without renaming | on its workspace. A lowercase search ignores case; any capital letter makes
it match case exactly (like vim's `smartcase`). The search wraps round:
monitors left to right, workspaces top to bottom, windows in loop order.
| Key | Action |
| ----------------------- | -------------------------------------- |
| Enter | Keep the match; Enter again focuses it |
| Escape | Go back to where the search started |
| Backspace (empty field) | Same as Escape |
**Window loop** **Window loop**
@@ -284,6 +293,7 @@ a digit, `F1`–`F12`, `Space`, or `Tab` (for example `Ctrl+N`, `Super+Space`).
| Up / Down | Previous / next workspace and show its windows | | Up / Down | Previous / next workspace and show its windows |
| Escape | Fold back to the carousel (closes entirely if opened via `windows`) | | Escape | Fold back to the carousel (closes entirely if opened via `windows`) |
| `keys.windows` (default Tab) | Fold back to the carousel | | `keys.windows` (default Tab) | Fold back to the carousel |
| `/`, `n` / `N` | Search windows, as in the carousel |
`Tab` and `Shift+Tab` also step windows, unless `keys.windows` is `Tab` (the `Tab` and `Shift+Tab` also step windows, unless `keys.windows` is `Tab` (the
default), in which case `Tab` folds the loop back instead. default), in which case `Tab` folds the loop back instead.
@@ -353,7 +363,7 @@ loop.
``` ```
app-carousel/ # launcher: shell.qml, config, theme, cards app-carousel/ # launcher: shell.qml, config, theme, cards
workspace-manager/ # overview: carousel, rename bar, window loop, compositor bridge workspace-manager/ # overview: carousel, window search, window loop, compositor bridge
workspace-badge/ # corner badge: name, color, rename and color editor workspace-badge/ # corner badge: name, color, rename and color editor
skygqts.nu # the `skygqts` CLI (Nushell) skygqts.nu # the `skygqts` CLI (Nushell)
package.nix # package definition package.nix # package definition
+4 -4
View File
@@ -37,7 +37,7 @@ def "main workspace-manager" [
} }
} }
# Toggle the rename bar. Also closes the carousel. # Toggle the workspace carousel. Also closes it.
def "main workspace-manager toggle" [] { def "main workspace-manager toggle" [] {
ws-ipc "toggle" ws-ipc "toggle"
} }
@@ -52,9 +52,9 @@ def "main workspace-manager windows" [] {
ws-ipc "openWindowSelection" ws-ipc "openWindowSelection"
} }
# Open the workspace carousel with the name field focused # Open the workspace carousel with the window search bar open
def "main workspace-manager rename" [] { def "main workspace-manager search" [] {
ws-ipc "openWorkspaceRename" ws-ipc "openSearch"
} }
const BADGE_PATH = $REPO_ROOT | path join "workspace-badge" const BADGE_PATH = $REPO_ROOT | path join "workspace-badge"
+2 -3
View File
@@ -1,12 +1,11 @@
{ {
"keys": { "keys": {
"rename": "Ctrl+N",
"windows": "Ctrl+G" "windows": "Ctrl+G"
}, },
"hints": { "hints": {
"show": true, "show": true,
"rename": "{key}: to switch here",
"windows": "{key}: to see windows", "windows": "{key}: to see windows",
"exitWindows": "{key} or Esc: to exit window carousel" "exitWindows": "{key} or Esc: to exit window carousel",
"search": "/: to search windows, n / N: next / previous match"
} }
} }
+4 -71
View File
@@ -26,10 +26,6 @@ Item {
return ""; return "";
} }
// Name of the focused workspace, empty when it has none.
property string currentName: ""
// Id of the focused workspace, -1 when unknown. Only Hyprland needs it.
property int currentId: -1
// Monitors left to right, each with its workspaces in order. // Monitors left to right, each with its workspaces in order.
// A nested list of parsed JSON, so this stays an untyped array. // A nested list of parsed JSON, so this stays an untyped array.
@@ -305,8 +301,7 @@ Item {
function buildMonitors(parsed): void { function buildMonitors(parsed): void {
const list = Array.isArray(parsed) ? parsed : []; const list = Array.isArray(parsed) ? parsed : [];
const groups = {}; const groups = {};
let focusedId = -1; let anyFocused = false;
let focusedName = "";
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
const ws = list[i]; const ws = list[i];
@@ -331,10 +326,8 @@ Item {
focused: focused focused: focused
}); });
if (focused) { if (focused)
focusedId = id; anyFocused = true;
focusedName = name;
}
} }
const names = Object.keys(groups); const names = Object.keys(groups);
@@ -360,14 +353,8 @@ Item {
}); });
} }
if (focusedId < 0) { if (!anyFocused)
console.warn("workspace-manager: no focused workspace reported"); console.warn("workspace-manager: no focused workspace reported");
root.currentId = -1;
root.currentName = "";
} else {
root.currentId = focusedId;
root.currentName = focusedName;
}
root.monitors = built; root.monitors = built;
root.refreshed(); root.refreshed();
} }
@@ -464,60 +451,6 @@ Item {
return 0; return 0;
} }
function apply(name: string): void {
const trimmed = name.trim();
if (root.kind === "niri") {
action.command = trimmed.length > 0 ? ["niri", "msg", "action", "set-workspace-name", trimmed] : ["niri", "msg", "action", "unset-workspace-name"];
} else if (root.kind === "hyprland") {
if (root.currentId < 0)
return;
const id = String(root.currentId);
// Hyprland has no "clear name", so fall back to the numeric id.
action.command = ["hyprctl", "dispatch", "renameworkspace", id, trimmed.length > 0 ? trimmed : id];
} else {
return;
}
action.running = false;
action.running = true;
root.currentName = trimmed;
}
// Rename a workspace by index (niri) or id (Hyprland).
// Used from the carousel to rename the selected workspace.
function renameWorkspace(wsId: int, wsIdx: int, name: string): void {
const trimmed = name.trim();
if (root.kind === "niri") {
// niri's --workspace flag accepts an index (number) or name (string).
if (trimmed.length > 0)
action.command = ["niri", "msg", "action", "set-workspace-name", "--workspace", String(wsIdx), trimmed];
else
action.command = ["niri", "msg", "action", "unset-workspace-name", String(wsIdx)];
} else if (root.kind === "hyprland") {
if (wsId < 0)
return;
const id = String(wsId);
action.command = ["hyprctl", "dispatch", "renameworkspace", id, trimmed.length > 0 ? trimmed : id];
} else {
return;
}
action.running = false;
action.running = true;
// Update the name locally so the carousel reflects it immediately.
if (root.currentId === wsId)
root.currentName = trimmed;
const mons = root.monitors;
for (let i = 0; i < mons.length; i++) {
const wsList = mons[i].workspaces ?? [];
for (let j = 0; j < wsList.length; j++) {
if (wsList[j].id === wsId) {
wsList[j].name = trimmed;
// reassign to trigger QML re-evaluation
root.monitors = root.monitors.slice();
return;
}
}
}
}
// Niri indexes count on the focused monitor only, so focus that monitor // Niri indexes count on the focused monitor only, so focus that monitor
// first, then the index. Hyprland switches by workspace id in one command. // first, then the index. Hyprland switches by workspace id in one command.
+5 -5
View File
@@ -11,16 +11,15 @@ Item {
readonly property string configPath: Quickshell.env("SKYG_WORKSPACE_MANAGER") ?? "" readonly property string configPath: Quickshell.env("SKYG_WORKSPACE_MANAGER") ?? ""
// Keys written as modifiers plus one key, like "Ctrl+N". // Keys written as modifiers plus one key, like "Ctrl+N".
property string renameKey
property string windowsKey property string windowsKey
property bool showHints property bool showHints
// "{key}" in a hint is replaced by its key. // "{key}" in a hint is replaced by its key.
property string renameHint
property string windowsHint property string windowsHint
property string exitWindowsHint property string exitWindowsHint
// The search keys (/, n, N) are fixed, like in vim.
property string searchHint
readonly property string renameHintText: root.fillKey(root.renameHint, root.renameKey)
readonly property string windowsHintText: root.fillKey(root.windowsHint, root.windowsKey) readonly property string windowsHintText: root.fillKey(root.windowsHint, root.windowsKey)
readonly property string exitWindowsHintText: root.fillKey(root.exitWindowsHint, root.windowsKey) readonly property string exitWindowsHintText: root.fillKey(root.exitWindowsHint, root.windowsKey)
@@ -67,12 +66,13 @@ Item {
function load(parsed): void { function load(parsed): void {
const keys = parsed.keys ?? {}; const keys = parsed.keys ?? {};
const hints = parsed.hints ?? {}; const hints = parsed.hints ?? {};
root.renameKey = root.keyOr(keys.rename, "Ctrl+N", "keys.rename");
root.windowsKey = root.keyOr(keys.windows, "Tab", "keys.windows"); root.windowsKey = root.keyOr(keys.windows, "Tab", "keys.windows");
root.showHints = root.boolOr(hints.show, true, "hints.show"); root.showHints = root.boolOr(hints.show, true, "hints.show");
root.renameHint = root.textOr(hints.rename, "{key}: to switch here", "hints.rename");
root.windowsHint = root.textOr(hints.windows, "{key}: to see windows", "hints.windows"); root.windowsHint = root.textOr(hints.windows, "{key}: to see windows", "hints.windows");
root.exitWindowsHint = root.textOr(hints.exitWindows, "{key} or Esc: to exit window carousel", "hints.exitWindows"); root.exitWindowsHint = root.textOr(hints.exitWindows, "{key} or Esc: to exit window carousel", "hints.exitWindows");
root.searchHint = root.textOr(hints.search, "/: to search windows, n / N: next / previous match", "hints.search");
} }
// ── keys ──────────────────────────────────────────────────────────── // ── keys ────────────────────────────────────────────────────────────
+268 -88
View File
@@ -9,8 +9,8 @@ PanelWindow {
required property Compositor compositor required property Compositor compositor
required property Theme theme required property Theme theme
required property Config config required property Config config
// Focus the name field as soon as the carousel has its data. // Open the search bar as soon as the carousel has its data.
required property bool renameOnOpen required property bool searchOnOpen
// Open the window loop on the focused workspace as soon as the carousel // Open the window loop on the focused workspace as soon as the carousel
// has its data. Escape then closes everything. // has its data. Escape then closes everything.
required property bool openWindowsOnOpen required property bool openWindowsOnOpen
@@ -42,8 +42,20 @@ PanelWindow {
property bool seedPending: false property bool seedPending: false
property bool animate: false property bool animate: false
// Whether the name field (rename mode) currently has focus. // The search bar is open and taking typed text.
property bool nameFieldActive: false property bool searchActive: false
// Last accepted search, used by n and N.
property string searchQuery: ""
// Matches for the text in the search bar, and which one is shown.
// matchIndex is -1 when none is shown.
property int matchCount: 0
property int matchIndex: -1
// Where the view was when the search bar opened. Escape goes back here.
property int originMonitor: 0
property list<int> originIndices: []
// -1 when the window loop was closed.
property int originWindowIndex: -1
property bool originCanCollapse: true
// The window loop is open on top of the selected workspace. // The window loop is open on top of the selected workspace.
property bool windowsOpen: false property bool windowsOpen: false
@@ -105,7 +117,6 @@ PanelWindow {
copy.push(0); copy.push(0);
copy[root.monitorIndex] = next; copy[root.monitorIndex] = next;
root.workspaceIndices = copy; root.workspaceIndices = copy;
root.syncNameField();
} }
function moveMonitor(delta: int): void { function moveMonitor(delta: int): void {
@@ -117,7 +128,6 @@ PanelWindow {
if (next < 0 || next >= count) if (next < 0 || next >= count)
return; return;
root.monitorIndex = next; root.monitorIndex = next;
root.syncNameField();
} }
function activateAt(monitorAt: int, workspaceAt: int): void { function activateAt(monitorAt: int, workspaceAt: int): void {
@@ -140,8 +150,7 @@ PanelWindow {
root.activateAt(root.monitorIndex, root.workspaceIndexAt(root.monitorIndex)); root.activateAt(root.monitorIndex, root.workspaceIndexAt(root.monitorIndex));
} }
// ── rename bar helpers ────────────────────────────────────────────── // A workspace from parsed JSON, so this stays untyped.
function selectedWorkspace(): var { function selectedWorkspace(): var {
const mons = root.compositor.monitors ?? []; const mons = root.compositor.monitors ?? [];
if (root.monitorIndex < 0 || root.monitorIndex >= mons.length) if (root.monitorIndex < 0 || root.monitorIndex >= mons.length)
@@ -153,23 +162,6 @@ PanelWindow {
return wsList[idx]; return wsList[idx];
} }
function syncNameField(): void {
const ws = root.selectedWorkspace();
nameInput.text = ws ? ws.name : "";
}
function enterRename(): void {
root.nameFieldActive = true;
root.syncNameField();
nameInput.forceActiveFocus();
nameInput.selectAll();
}
function leaveRename(): void {
root.nameFieldActive = false;
nameInput.focus = false;
Qt.callLater(() => focusScope.forceActiveFocus());
}
// ── window loop helpers ───────────────────────────────────────────── // ── window loop helpers ─────────────────────────────────────────────
@@ -215,22 +207,201 @@ PanelWindow {
root.requestBack(); root.requestBack();
} }
function isToggleRenameKey(event): bool { // ── search ──────────────────────────────────────────────────────────
return root.config.matches(event, root.config.renameKey);
function noCtrlOrAlt(event): bool {
return !(event.modifiers & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier));
} }
function applyRename(): void { function isSearchKey(event): bool {
const ws = root.selectedWorkspace(); return event.text === "/" && root.noCtrlOrAlt(event);
if (ws) }
root.compositor.renameWorkspace(ws.id, ws.idx, nameInput.text);
root.leaveRename(); // n goes forward (1), N goes back (-1), anything else is 0.
function nextMatchDirection(event): int {
if (event.key !== Qt.Key_N || !root.noCtrlOrAlt(event))
return 0;
return (event.modifiers & Qt.ShiftModifier) ? -1 : 1;
}
// Selected window in the loop, or -1 when the loop is closed.
function currentWindowIndex(): int {
return root.windowsOpen ? windowLoop.selectedIndex : -1;
}
// Order: monitor, then workspace, then window. A closed loop (-1)
// comes before every window of its workspace.
function comparePositions(monitorA: int, workspaceA: int, windowA: int, monitorB: int, workspaceB: int, windowB: int): int {
if (monitorA !== monitorB)
return monitorA - monitorB;
if (workspaceA !== workspaceB)
return workspaceA - workspaceB;
return windowA - windowB;
}
// Like vim's smartcase: any capital letter makes the search match case.
// The window is parsed JSON, so it stays untyped.
function windowMatches(w, query: string): bool {
const exact = query !== query.toLowerCase();
const fold = text => exact ? text : text.toLowerCase();
const wanted = fold(query);
return fold(w.title ?? "").includes(wanted) || fold(w.app ?? "").includes(wanted);
}
// Every window whose title or app matches, in carousel order, as
// { monitor, workspace, window } list positions.
function findMatches(query: string): var {
const found = [];
if (query.length === 0)
return found;
const mons = root.compositor.monitors ?? [];
for (let i = 0; i < mons.length; i++) {
const wsList = mons[i].workspaces ?? [];
for (let j = 0; j < wsList.length; j++) {
const wins = wsList[j].windows ?? [];
for (let k = 0; k < wins.length; k++) {
if (root.windowMatches(wins[k], query))
found.push({
monitor: i,
workspace: j,
window: k
});
}
}
}
return found;
}
// The first match after the given place (direction 1) or the last one
// before it (direction -1), wrapping round. -1 when there is none.
function pickMatch(matches, monitorAt: int, workspaceAt: int, windowAt: int, direction: int): int {
if (matches.length === 0)
return -1;
if (direction > 0) {
for (let i = 0; i < matches.length; i++) {
const m = matches[i];
if (root.comparePositions(m.monitor, m.workspace, m.window, monitorAt, workspaceAt, windowAt) > 0)
return i;
}
return 0;
}
for (let i = matches.length - 1; i >= 0; i--) {
const m = matches[i];
if (root.comparePositions(m.monitor, m.workspace, m.window, monitorAt, workspaceAt, windowAt) < 0)
return i;
}
return matches.length - 1;
}
// Move the view to a workspace, and to one of its windows unless
// windowAt is -1, which closes the loop.
function showPosition(monitorAt: int, workspaceAt: int, windowAt: int): void {
const mons = root.compositor.monitors ?? [];
if (monitorAt < 0 || monitorAt >= mons.length)
return;
const wsList = mons[monitorAt].workspaces ?? [];
if (workspaceAt < 0 || workspaceAt >= wsList.length)
return;
const ws = wsList[workspaceAt];
const forward = root.comparePositions(monitorAt, workspaceAt, windowAt, root.monitorIndex, root.workspaceIndexAt(root.monitorIndex), root.currentWindowIndex()) >= 0;
root.animate = true;
root.monitorIndex = monitorAt;
const copy = root.workspaceIndices.slice();
while (copy.length <= monitorAt)
copy.push(0);
copy[monitorAt] = workspaceAt;
root.workspaceIndices = copy;
if (windowAt < 0) {
if (root.windowsOpen)
root.collapseWindows();
return;
}
if (!root.windowsOpen) {
root.expandWindows(true);
} else if (root.loopWorkspaceId !== ws.id) {
windowLoop.holdLeaving();
root.loopWorkspaceId = ws.id;
windowLoop.switchIn(forward ? 1 : -1);
}
windowLoop.selectIndex(windowAt);
}
function restoreOrigin(): void {
const indices = Array.from(root.originIndices);
const workspaceAt = root.originMonitor < indices.length ? indices[root.originMonitor] : 0;
root.showPosition(root.originMonitor, workspaceAt, root.originWindowIndex);
root.workspaceIndices = indices;
root.canCollapse = root.originCanCollapse;
}
function enterSearch(): void {
root.originMonitor = root.monitorIndex;
root.originIndices = root.workspaceIndices.slice();
root.originWindowIndex = root.currentWindowIndex();
root.originCanCollapse = root.canCollapse;
root.matchCount = 0;
root.matchIndex = -1;
// Clear before turning on, so the cleared text does not search.
searchInput.text = "";
root.searchActive = true;
searchInput.forceActiveFocus();
}
function leaveSearch(): void {
root.searchActive = false;
searchInput.focus = false;
Qt.callLater(() => focusScope.forceActiveFocus());
}
// Called as the search text changes. Jumps to the first match after
// where the search started, or back there when nothing matches.
function updateSearch(query: string): void {
const matches = root.findMatches(query);
root.matchCount = matches.length;
const indices = Array.from(root.originIndices);
const workspaceAt = root.originMonitor < indices.length ? indices[root.originMonitor] : 0;
const index = root.pickMatch(matches, root.originMonitor, workspaceAt, root.originWindowIndex, 1);
root.matchIndex = index;
if (index < 0) {
root.restoreOrigin();
return;
}
const m = matches[index];
root.showPosition(m.monitor, m.workspace, m.window);
}
// Enter: keep the shown match and remember the text for n and N.
function acceptSearch(): void {
if (searchInput.text.length > 0)
root.searchQuery = searchInput.text;
root.leaveSearch();
}
// Escape: go back to where the search started.
function cancelSearch(): void {
root.restoreOrigin();
root.leaveSearch();
}
function jumpToMatch(direction: int): void {
const matches = root.findMatches(root.searchQuery);
const index = root.pickMatch(matches, root.monitorIndex, root.workspaceIndexAt(root.monitorIndex), root.currentWindowIndex(), direction);
root.matchCount = matches.length;
root.matchIndex = index;
if (index < 0)
return;
const m = matches[index];
root.showPosition(m.monitor, m.workspace, m.window);
} }
// ── visibility handling ───────────────────────────────────────────── // ── visibility handling ─────────────────────────────────────────────
onVisibleChanged: { onVisibleChanged: {
root.animate = false; root.animate = false;
root.nameFieldActive = false; root.searchActive = false;
searchInput.focus = false;
root.windowsOpen = false; root.windowsOpen = false;
if (!root.visible) { if (!root.visible) {
root.seedPending = false; root.seedPending = false;
@@ -251,11 +422,10 @@ PanelWindow {
return; return;
root.seedPending = false; root.seedPending = false;
root.seedSelection(); root.seedSelection();
root.syncNameField();
if (root.openWindowsOnOpen) if (root.openWindowsOnOpen)
root.expandWindows(false); root.expandWindows(false);
if (root.renameOnOpen) if (root.searchOnOpen)
root.enterRename(); root.enterSearch();
} }
} }
@@ -269,8 +439,8 @@ PanelWindow {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (root.nameFieldActive) if (root.searchActive)
root.leaveRename(); root.cancelSearch();
else if (root.windowsOpen) else if (root.windowsOpen)
root.leaveWindows(); root.leaveWindows();
else else
@@ -279,16 +449,25 @@ PanelWindow {
} }
} }
// ── rename bar (always visible at the top) ────────────────────────── // ── search bar (shown while searching) ──────────────────────────────
Item { Item {
id: renameBar id: searchBar
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: root.theme.renameBarTop anchors.topMargin: root.theme.searchBarTop
width: root.theme.barWidth width: root.theme.barWidth
height: root.theme.barHeight height: root.theme.barHeight
z: 10 z: 10
opacity: root.searchActive ? 1 : 0
// Shown at once when opened, so the field can take focus.
visible: root.searchActive || searchBar.opacity > 0
Behavior on opacity {
NumberAnimation {
duration: root.theme.hintFadeDuration
}
}
Glass { Glass {
anchors.fill: parent anchors.fill: parent
@@ -321,17 +500,18 @@ PanelWindow {
} }
Text { Text {
id: label id: prompt
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: "Workspace Name: " text: "/"
color: root.theme.labelColor color: root.theme.labelColor
font.pixelSize: root.theme.fontSize font.pixelSize: root.theme.fontSize
font.bold: true
} }
Item { Item {
id: field id: field
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3 width: parent.width - prompt.width - matchText.width - root.theme.logoSize - root.theme.barSpacing * 3
height: root.theme.barHeight - root.theme.barPadding * 2 height: root.theme.barHeight - root.theme.barPadding * 2
Glass { Glass {
@@ -339,12 +519,12 @@ PanelWindow {
theme: root.theme theme: root.theme
radius: root.theme.cornerRadius / 2 radius: root.theme.cornerRadius / 2
tint: root.theme.fieldBg tint: root.theme.fieldBg
selected: nameInput.activeFocus selected: searchInput.activeFocus
shadow: false shadow: false
} }
TextInput { TextInput {
id: nameInput id: searchInput
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: root.theme.fieldPadding anchors.leftMargin: root.theme.fieldPadding
anchors.rightMargin: root.theme.fieldPadding anchors.rightMargin: root.theme.fieldPadding
@@ -357,61 +537,55 @@ PanelWindow {
clip: true clip: true
focus: false focus: false
onAccepted: root.applyRename() onTextChanged: {
if (root.searchActive)
root.updateSearch(searchInput.text);
}
onAccepted: root.acceptSearch()
// Escape from rename field returns to carousel.
Keys.onEscapePressed: event => { Keys.onEscapePressed: event => {
root.leaveRename(); root.cancelSearch();
event.accepted = true; event.accepted = true;
} }
// Backspace on an empty search closes it, like in vim.
// The rename key toggles back to carousel.
Keys.onShortcutOverride: event => {
if (root.isToggleRenameKey(event))
event.accepted = true;
}
Keys.onPressed: event => { Keys.onPressed: event => {
if (root.isToggleRenameKey(event)) { if (event.key === Qt.Key_Backspace && searchInput.text.length === 0) {
root.leaveRename(); root.cancelSearch();
event.accepted = true; event.accepted = true;
return;
} }
event.accepted = false;
} }
} }
} }
Rectangle { // "2/5" while there are matches, "no match" when none.
id: okButton Text {
id: matchText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: root.theme.buttonWidth color: root.matchCount > 0 ? root.theme.labelColor : root.theme.fieldBorder
height: root.theme.barHeight - root.theme.barPadding * 2 font.pixelSize: root.theme.fontSize
radius: root.theme.cornerRadius / 2 text: {
color: okArea.pressed ? Qt.darker(root.theme.buttonBg, 1.2) : root.theme.buttonBg if (searchInput.text.length === 0)
return "";
Text { if (root.matchCount === 0)
anchors.centerIn: parent return "no match";
text: "OK" return (root.matchIndex + 1) + "/" + root.matchCount;
color: root.theme.buttonText
font.pixelSize: root.theme.fontSize
font.bold: true
}
MouseArea {
id: okArea
anchors.fill: parent
onClicked: root.applyRename()
} }
} }
} }
} }
}
KeyHint { // Where the search bar opens, while it is closed.
anchors.right: parent.right KeyHint {
anchors.top: parent.bottom anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: root.theme.hintGap anchors.top: parent.top
theme: root.theme anchors.topMargin: root.theme.searchBarTop
hint: root.config.renameHintText z: 10
shown: root.config.showHints && !root.nameFieldActive theme: root.theme
} hint: root.config.searchHint
shown: root.config.showHints && !root.searchActive
} }
// ── carousel ──────────────────────────────────────────────────────── // ── carousel ────────────────────────────────────────────────────────
@@ -422,9 +596,15 @@ PanelWindow {
focus: root.visible focus: root.visible
Keys.onPressed: event => { Keys.onPressed: event => {
// The rename key toggles to rename mode. // / opens the search bar, n and N go to the next or previous match.
if (root.isToggleRenameKey(event)) { if (root.isSearchKey(event)) {
root.enterRename(); root.enterSearch();
event.accepted = true;
return;
}
const direction = root.nextMatchDirection(event);
if (direction !== 0) {
root.jumpToMatch(direction);
event.accepted = true; event.accepted = true;
return; return;
} }
@@ -612,7 +792,7 @@ PanelWindow {
} }
} }
// Monitor name, above the rename bar. // Monitor name, above the search bar.
Item { Item {
id: monitorName id: monitorName
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
-178
View File
@@ -1,178 +0,0 @@
import QtQuick
import Quickshell
import Quickshell.Wayland
PanelWindow {
id: root
required property bool shellOpen
required property Compositor compositor
required property Theme theme
signal requestClose
signal requestGoto
visible: root.shellOpen
color: "transparent"
implicitWidth: root.theme.barWidth
implicitHeight: root.theme.barHeight
exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "quickshell:workspace-manager"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
// No anchors: the layer surface is then centered on the screen.
onVisibleChanged: {
if (!root.visible)
return;
root.compositor.refresh();
nameField.text = root.compositor.currentName;
Qt.callLater(() => {
nameField.forceActiveFocus();
nameField.selectAll();
});
}
Connections {
target: root.compositor
function onRefreshed(): void {
if (root.visible) {
nameField.text = root.compositor.currentName;
nameField.selectAll();
}
}
}
function accept(): void {
root.compositor.apply(nameField.text);
root.requestClose();
}
function isGotoKey(event): bool {
const mods = event.modifiers;
const ctrl = (mods & Qt.ControlModifier) && !(mods & Qt.AltModifier) && !(mods & Qt.MetaModifier);
return event.key === Qt.Key_G && ctrl;
}
Glass {
anchors.fill: parent
theme: root.theme
radius: root.theme.cornerRadius
tint: root.theme.barBg
selected: false
// The window is only as big as the bar, so a shadow would be cut off.
shadow: false
}
Item {
anchors.fill: parent
Row {
anchors.fill: parent
anchors.margins: root.theme.barPadding
spacing: root.theme.barSpacing
Image {
width: root.theme.logoSize
height: root.theme.logoSize
anchors.verticalCenter: parent.verticalCenter
source: root.compositor.logoSource
visible: root.compositor.logoSource !== ""
sourceSize.width: root.theme.logoSize * 2
sourceSize.height: root.theme.logoSize * 2
fillMode: Image.PreserveAspectFit
smooth: true
// Raster source, so filter the downscale.
mipmap: true
}
Text {
id: label
anchors.verticalCenter: parent.verticalCenter
text: "Workspace Name: "
color: root.theme.labelColor
font.pixelSize: root.theme.fontSize
}
Item {
id: field
anchors.verticalCenter: parent.verticalCenter
width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3
height: root.theme.barHeight - root.theme.barPadding * 2
Glass {
anchors.fill: parent
theme: root.theme
radius: root.theme.cornerRadius / 2
tint: root.theme.fieldBg
selected: nameField.activeFocus
shadow: false
}
TextInput {
id: nameField
anchors.fill: parent
anchors.leftMargin: root.theme.fieldPadding
anchors.rightMargin: root.theme.fieldPadding
verticalAlignment: TextInput.AlignVCenter
color: root.theme.textColor
font.pixelSize: root.theme.fontSize
selectByMouse: true
selectionColor: root.theme.fieldBorder
selectedTextColor: root.theme.buttonText
clip: true
focus: root.visible
onAccepted: root.accept()
Keys.onEscapePressed: event => {
root.requestClose();
event.accepted = true;
}
// Ctrl+G opens the carousel. A plain G still types into the name.
// Other keys must be rejected, or the field would swallow them.
Keys.onShortcutOverride: event => {
if (root.isGotoKey(event))
event.accepted = true;
}
Keys.onPressed: event => {
if (!root.isGotoKey(event)) {
event.accepted = false;
return;
}
root.requestGoto();
event.accepted = true;
}
}
}
Rectangle {
id: okButton
anchors.verticalCenter: parent.verticalCenter
width: root.theme.buttonWidth
height: root.theme.barHeight - root.theme.barPadding * 2
radius: root.theme.cornerRadius / 2
color: okArea.pressed ? Qt.darker(root.theme.buttonBg, 1.2) : root.theme.buttonBg
Text {
anchors.centerIn: parent
text: "OK"
color: root.theme.buttonText
font.pixelSize: root.theme.fontSize
font.bold: true
}
MouseArea {
id: okArea
anchors.fill: parent
onClicked: root.accept()
}
}
}
}
}
+5 -5
View File
@@ -36,7 +36,7 @@ QtObject {
readonly property real fieldPadding: 14 readonly property real fieldPadding: 14
readonly property real logoSize: 36 readonly property real logoSize: 36
readonly property real fontSize: 24 readonly property real fontSize: 24
readonly property real buttonWidth: 86
// Fullscreen dim behind the workspace carousel. // Fullscreen dim behind the workspace carousel.
readonly property color backdrop: "#0d0b0e14" readonly property color backdrop: "#0d0b0e14"
@@ -47,12 +47,12 @@ QtObject {
readonly property real cardRadius: 16 readonly property real cardRadius: 16
readonly property real monitorLabelSize: 18 readonly property real monitorLabelSize: 18
// Distance from the top of the screen to each monitor's name, // Distance from the top of the screen to each monitor's name,
// which sits above the rename bar. // which sits above the search bar.
readonly property real monitorLabelTop: 20 readonly property real monitorLabelTop: 20
readonly property real monitorNameSize: 22 readonly property real monitorNameSize: 22
readonly property real monitorNamePadding: 25 readonly property real monitorNamePadding: 25
// Distance from the top of the screen to the rename bar. // Distance from the top of the screen to the search bar.
readonly property real renameBarTop: 76 readonly property real searchBarTop: 76
// Each monitor is a column of its workspaces. One step between // Each monitor is a column of its workspaces. One step between
// monitors (sideways), and one step between workspaces (down). // monitors (sideways), and one step between workspaces (down).
@@ -76,7 +76,7 @@ QtObject {
readonly property real windowRowSpacing: 6 readonly property real windowRowSpacing: 6
readonly property int maxWindowRows: 3 readonly property int maxWindowRows: 3
// Key hints. They sit under the rename bar, the selected workspace and // Key hints. They sit under the search bar, the selected workspace and
// the front window, this far below each. // the front window, this far below each.
readonly property real hintSize: 12 readonly property real hintSize: 12
readonly property real hintGap: 8 readonly property real hintGap: 8
+12
View File
@@ -190,6 +190,18 @@ Item {
root.turn = root.targetStep; root.turn = root.targetStep;
} }
// Turn to the window at this list index, the short way round.
function selectIndex(index: int): void {
if (root.count === 0 || index < 0 || index >= root.count)
return;
let delta = index - root.selectedIndex;
if (delta > root.count / 2)
delta -= root.count;
else if (delta < -root.count / 2)
delta += root.count;
root.step(delta);
}
function activateAt(index: int): void { function activateAt(index: int): void {
const list = root.windows; const list = root.windows;
if (index < 0 || index >= list.length) if (index < 0 || index >= list.length)
+8 -8
View File
@@ -6,8 +6,8 @@ ShellRoot {
id: shell id: shell
property bool open: false property bool open: false
// Focus the name field once the carousel opens. // Open the search bar once the carousel opens.
property bool renameOnOpen: false property bool searchOnOpen: false
// Open the window loop on the focused workspace once the carousel opens. // Open the window loop on the focused workspace once the carousel opens.
property bool openWindowsOnOpen: false property bool openWindowsOnOpen: false
@@ -35,15 +35,15 @@ ShellRoot {
shell.open = false; shell.open = false;
} }
function openWith(rename: bool, windows: bool): void { function openWith(search: bool, windows: bool): void {
shell.renameOnOpen = rename; shell.searchOnOpen = search;
shell.openWindowsOnOpen = windows; shell.openWindowsOnOpen = windows;
// Already open, so there is no fresh open to wait for. // Already open, so there is no fresh open to wait for.
if (shell.open) { if (shell.open) {
if (windows) if (windows)
gotoView.expandWindows(false); gotoView.expandWindows(false);
if (rename) if (search)
gotoView.enterRename(); gotoView.enterSearch();
return; return;
} }
shell.open = true; shell.open = true;
@@ -67,7 +67,7 @@ ShellRoot {
shell.openWith(false, true); shell.openWith(false, true);
} }
function openWorkspaceRename(): void { function openSearch(): void {
shell.openWith(true, false); shell.openWith(true, false);
} }
} }
@@ -78,7 +78,7 @@ ShellRoot {
compositor: compositor compositor: compositor
theme: theme theme: theme
config: config config: config
renameOnOpen: shell.renameOnOpen searchOnOpen: shell.searchOnOpen
openWindowsOnOpen: shell.openWindowsOnOpen openWindowsOnOpen: shell.openWindowsOnOpen
onRequestClose: shell.closeAll() onRequestClose: shell.closeAll()
onRequestBack: shell.closeAll() onRequestBack: shell.closeAll()