previewer
This commit is contained in:
1 parent
d4684f337f
commit
2432c43f5f
16 files changed
+1029
-180
No files matched your search
+1
-1
@@ -43,7 +43,7 @@
|
|||||||
"INTRO_MESSAGE": "It's gettin' Flox in here"
|
"INTRO_MESSAGE": "It's gettin' Flox in here"
|
||||||
},
|
},
|
||||||
"hook": {
|
"hook": {
|
||||||
"on-activate": " export NIXPKGS_QT6_QML_IMPORT_PATH=\"$FLOX_ENV/lib/qt-6/qml${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}\"\n export QTWEBENGINEPROCESS_PATH=\"$FLOX_ENV/libexec/QtWebEngineProcess\"\n export SKYG_APP_CAROUSEL=$FLOX_ENV_PROJECT/example.json\n alias skygqts = $FLOX_ENV_PROJECT/skygqts.nu\n"
|
"on-activate": " export NIXPKGS_QT6_QML_IMPORT_PATH=\"$FLOX_ENV/lib/qt-6/qml${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}\"\n export QTWEBENGINEPROCESS_PATH=\"$FLOX_ENV/libexec/QtWebEngineProcess\"\n export SKYG_APP_CAROUSEL=$FLOX_ENV_PROJECT/example.json\n export CLAUDE_CONFIG_DIR=\"$FLOX_ENV_PROJECT/.claude-account\"\n alias skygqts = $FLOX_ENV_PROJECT/skygqts.nu\n"
|
||||||
},
|
},
|
||||||
"options": {}
|
"options": {}
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
+1
@@ -35,5 +35,6 @@ on-activate = '''
|
|||||||
export NIXPKGS_QT6_QML_IMPORT_PATH="$FLOX_ENV/lib/qt-6/qml${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}"
|
export NIXPKGS_QT6_QML_IMPORT_PATH="$FLOX_ENV/lib/qt-6/qml${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}"
|
||||||
export QTWEBENGINEPROCESS_PATH="$FLOX_ENV/libexec/QtWebEngineProcess"
|
export QTWEBENGINEPROCESS_PATH="$FLOX_ENV/libexec/QtWebEngineProcess"
|
||||||
export SKYG_APP_CAROUSEL=$FLOX_ENV_PROJECT/example.json
|
export SKYG_APP_CAROUSEL=$FLOX_ENV_PROJECT/example.json
|
||||||
|
export CLAUDE_CONFIG_DIR="$FLOX_ENV_PROJECT/.claude-account"
|
||||||
alias skygqts = $FLOX_ENV_PROJECT/skygqts.nu
|
alias skygqts = $FLOX_ENV_PROJECT/skygqts.nu
|
||||||
'''
|
'''
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.claude-account/
|
||||||
+2
-2
@@ -15,7 +15,7 @@ stdenvNoCC.mkDerivation {
|
|||||||
root = ./.;
|
root = ./.;
|
||||||
fileset = lib.fileset.unions [
|
fileset = lib.fileset.unions [
|
||||||
./app-carousel
|
./app-carousel
|
||||||
./workspace-rename
|
./workspace-manager
|
||||||
./skygqts.nu
|
./skygqts.nu
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@@ -28,7 +28,7 @@ stdenvNoCC.mkDerivation {
|
|||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/share/skygqts
|
mkdir -p $out/share/skygqts
|
||||||
cp -r app-carousel $out/share/skygqts/
|
cp -r app-carousel $out/share/skygqts/
|
||||||
cp -r workspace-rename $out/share/skygqts/
|
cp -r workspace-manager $out/share/skygqts/
|
||||||
cp skygqts.nu $out/share/skygqts/
|
cp skygqts.nu $out/share/skygqts/
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
makeWrapper ${lib.getExe nushell} $out/bin/skygqts \
|
makeWrapper ${lib.getExe nushell} $out/bin/skygqts \
|
||||||
|
|||||||
+16
-11
@@ -15,25 +15,30 @@ def "main carousel" [
|
|||||||
qs -p ($REPO_ROOT | path join "app-carousel")
|
qs -p ($REPO_ROOT | path join "app-carousel")
|
||||||
}
|
}
|
||||||
|
|
||||||
const WS_RENAME_PATH = $REPO_ROOT | path join "workspace-rename"
|
const WS_PATH = $REPO_ROOT | path join "workspace-manager"
|
||||||
|
|
||||||
# Send an IPC call to the running workspace rename bar
|
# Send an IPC call to the running workspace manager
|
||||||
def ws-rename-ipc [fn: string] {
|
def ws-ipc [fn: string] {
|
||||||
qs ipc -p $WS_RENAME_PATH call wsname $fn
|
qs ipc -p $WS_PATH call workspace $fn
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the workspace rename bar
|
# Run the workspace manager
|
||||||
def "main workspace-rename" [
|
def "main workspace-manager" [
|
||||||
--daemon (-d) # detach from the terminal
|
--daemon (-d) # detach from the terminal
|
||||||
] {
|
] {
|
||||||
if $daemon {
|
if $daemon {
|
||||||
qs -d -n -p $WS_RENAME_PATH
|
qs -d -n -p $WS_PATH
|
||||||
} else {
|
} else {
|
||||||
qs -n -p $WS_RENAME_PATH
|
qs -n -p $WS_PATH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Toggle the workspace rename bar
|
# Toggle the rename bar. Also closes the carousel.
|
||||||
def "main workspace-rename toggle" [] {
|
def "main workspace-manager toggle" [] {
|
||||||
ws-rename-ipc "toggle"
|
ws-ipc "toggle"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Open the workspace carousel
|
||||||
|
def "main workspace-manager goto" [] {
|
||||||
|
ws-ipc "goTo"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,419 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
// Talks to whichever compositor is running. Everything goes through the
|
||||||
|
// command line tools so this file works the same on niri and Hyprland.
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// "niri", "hyprland" or "" when neither was detected.
|
||||||
|
readonly property string kind: {
|
||||||
|
if (Quickshell.env("NIRI_SOCKET"))
|
||||||
|
return "niri";
|
||||||
|
if (Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE"))
|
||||||
|
return "hyprland";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property string logoSource: {
|
||||||
|
if (root.kind === "niri")
|
||||||
|
return Qt.resolvedUrl("assets/niri.png");
|
||||||
|
if (root.kind === "hyprland")
|
||||||
|
return Qt.resolvedUrl("assets/hyprland.png");
|
||||||
|
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 top to bottom, each with its workspaces left to right.
|
||||||
|
// A nested list of parsed JSON, so this stays an untyped array.
|
||||||
|
property var monitors: []
|
||||||
|
|
||||||
|
// Output name -> { x, y, known, activeId, monitorFocused }.
|
||||||
|
// Held between the two query steps. Same reason as monitors.
|
||||||
|
property var outputLayout: ({})
|
||||||
|
|
||||||
|
// Raw workspace JSON saved between the workspaces and windows query stages.
|
||||||
|
property var workspaceData: []
|
||||||
|
// Normalized windows with { title, app, output, idx, id }.
|
||||||
|
property var windowList: []
|
||||||
|
|
||||||
|
// "" while idle, otherwise the query step currently running.
|
||||||
|
property string queryStage: ""
|
||||||
|
property bool refreshQueued: false
|
||||||
|
// False while a query is being restarted, so a leftover finish is ignored.
|
||||||
|
property bool acceptStream: false
|
||||||
|
|
||||||
|
// Argv arrays waiting to run. A list of lists, so this stays untyped.
|
||||||
|
property var focusQueue: []
|
||||||
|
property var focusPending: []
|
||||||
|
property bool focusRestart: false
|
||||||
|
|
||||||
|
signal refreshed
|
||||||
|
|
||||||
|
function refresh(): void {
|
||||||
|
if (root.kind === "")
|
||||||
|
return;
|
||||||
|
if (root.queryStage !== "") {
|
||||||
|
root.refreshQueued = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.startStage(root.kind === "niri" ? "outputs" : "monitors");
|
||||||
|
}
|
||||||
|
|
||||||
|
function startStage(stage: string): void {
|
||||||
|
root.acceptStream = false;
|
||||||
|
query.running = false;
|
||||||
|
root.queryStage = stage;
|
||||||
|
if (stage === "outputs")
|
||||||
|
query.command = ["niri", "msg", "--json", "outputs"];
|
||||||
|
else if (stage === "monitors")
|
||||||
|
query.command = ["hyprctl", "-j", "monitors"];
|
||||||
|
else if (stage === "workspaces") {
|
||||||
|
if (root.kind === "niri")
|
||||||
|
query.command = ["niri", "msg", "--json", "workspaces"];
|
||||||
|
else
|
||||||
|
query.command = ["hyprctl", "-j", "workspaces"];
|
||||||
|
} else if (stage === "windows") {
|
||||||
|
if (root.kind === "niri")
|
||||||
|
query.command = ["niri", "msg", "--json", "windows"];
|
||||||
|
else
|
||||||
|
query.command = ["hyprctl", "-j", "clients"];
|
||||||
|
}
|
||||||
|
root.acceptStream = true;
|
||||||
|
query.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishQuery(): void {
|
||||||
|
root.queryStage = "";
|
||||||
|
if (!root.refreshQueued)
|
||||||
|
return;
|
||||||
|
root.refreshQueued = false;
|
||||||
|
root.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function asString(value): string {
|
||||||
|
if (value === null || value === undefined)
|
||||||
|
return "";
|
||||||
|
return String(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function asNumber(value, fallback: int): int {
|
||||||
|
const number = Number(value);
|
||||||
|
return Number.isFinite(number) ? number : fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseOutputs(parsed): void {
|
||||||
|
const layout = {};
|
||||||
|
const list = Array.isArray(parsed) ? parsed : [];
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
const out = list[i];
|
||||||
|
const name = root.asString(out.name);
|
||||||
|
if (name.length === 0)
|
||||||
|
continue;
|
||||||
|
const logical = out.logical ?? {};
|
||||||
|
const x = root.asNumber(logical.x, 0);
|
||||||
|
const y = root.asNumber(logical.y, 0);
|
||||||
|
const known = Number.isFinite(Number(logical.x)) && Number.isFinite(Number(logical.y));
|
||||||
|
layout[name] = {
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
known: known,
|
||||||
|
activeId: -1,
|
||||||
|
monitorFocused: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
root.outputLayout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseMonitors(parsed): void {
|
||||||
|
const layout = {};
|
||||||
|
const list = Array.isArray(parsed) ? parsed : [];
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
const mon = list[i];
|
||||||
|
const name = root.asString(mon.name);
|
||||||
|
if (name.length === 0)
|
||||||
|
continue;
|
||||||
|
const known = Number.isFinite(Number(mon.x)) && Number.isFinite(Number(mon.y));
|
||||||
|
const active = mon.activeWorkspace ?? {};
|
||||||
|
layout[name] = {
|
||||||
|
x: root.asNumber(mon.x, 0),
|
||||||
|
y: root.asNumber(mon.y, 0),
|
||||||
|
known: known,
|
||||||
|
activeId: root.asNumber(active.id, -1),
|
||||||
|
monitorFocused: mon.focused === true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
root.outputLayout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hyprland reports the numeric id as the name when the workspace has none.
|
||||||
|
function workspaceName(rawName, id: int): string {
|
||||||
|
const name = root.asString(rawName);
|
||||||
|
if (root.kind === "hyprland" && name === String(id))
|
||||||
|
return "";
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseWindows(parsed): void {
|
||||||
|
const list = Array.isArray(parsed) ? parsed : [];
|
||||||
|
const windows = [];
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
const w = list[i];
|
||||||
|
let title, app, id;
|
||||||
|
if (root.kind === "niri") {
|
||||||
|
title = root.asString(w.title);
|
||||||
|
app = root.asString(w.app_id);
|
||||||
|
id = root.asNumber(w.workspace_id, -1);
|
||||||
|
} else {
|
||||||
|
if (w.mapped === false)
|
||||||
|
continue;
|
||||||
|
title = root.asString(w.title);
|
||||||
|
app = root.asString(w.class);
|
||||||
|
id = root.asNumber(w.workspace?.id, -1);
|
||||||
|
}
|
||||||
|
if (id < 0)
|
||||||
|
continue;
|
||||||
|
windows.push({ title: title, app: app, id: id });
|
||||||
|
}
|
||||||
|
root.windowList = windows;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both niri and Hyprland match windows by workspace id.
|
||||||
|
function matchWindow(w, output: string, idx: int, id: int): bool {
|
||||||
|
return w.id === id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildMonitors(parsed): void {
|
||||||
|
const list = Array.isArray(parsed) ? parsed : [];
|
||||||
|
const groups = {};
|
||||||
|
let focusedId = -1;
|
||||||
|
let focusedName = "";
|
||||||
|
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
const ws = list[i];
|
||||||
|
const id = root.asNumber(ws.id, -1);
|
||||||
|
if (root.kind === "hyprland" && id < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const output = root.asString(root.kind === "niri" ? ws.output : ws.monitor);
|
||||||
|
const idx = root.kind === "niri" ? root.asNumber(ws.idx, 0) : id;
|
||||||
|
const name = root.workspaceName(ws.name, id);
|
||||||
|
const meta = root.outputLayout[output] ?? {};
|
||||||
|
const active = root.kind === "niri" ? ws.is_active === true : id === meta.activeId;
|
||||||
|
const focused = root.kind === "niri" ? ws.is_focused === true : active && meta.monitorFocused === true;
|
||||||
|
|
||||||
|
if (!groups[output])
|
||||||
|
groups[output] = [];
|
||||||
|
groups[output].push({
|
||||||
|
id: id,
|
||||||
|
idx: idx,
|
||||||
|
name: name,
|
||||||
|
active: active,
|
||||||
|
focused: focused
|
||||||
|
});
|
||||||
|
|
||||||
|
if (focused) {
|
||||||
|
focusedId = id;
|
||||||
|
focusedName = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const names = Object.keys(groups);
|
||||||
|
names.sort((a, b) => root.compareOutputs(a, b));
|
||||||
|
|
||||||
|
const built = [];
|
||||||
|
for (let i = 0; i < names.length; i++) {
|
||||||
|
const name = names[i];
|
||||||
|
const workspaces = groups[name];
|
||||||
|
workspaces.sort((a, b) => a.idx - b.idx);
|
||||||
|
for (let j = 0; j < workspaces.length; j++) {
|
||||||
|
const ws = workspaces[j];
|
||||||
|
ws.windows = root.windowList.filter(w => root.matchWindow(w, name, ws.idx, ws.id));
|
||||||
|
}
|
||||||
|
const pos = root.outputLayout[name] ?? {};
|
||||||
|
built.push({
|
||||||
|
name: name,
|
||||||
|
x: root.asNumber(pos.x, 0),
|
||||||
|
y: root.asNumber(pos.y, 0),
|
||||||
|
workspaces: workspaces
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focusedId < 0) {
|
||||||
|
console.warn("workspace-manager: no focused workspace reported");
|
||||||
|
root.currentId = -1;
|
||||||
|
root.currentName = "";
|
||||||
|
} else {
|
||||||
|
root.currentId = focusedId;
|
||||||
|
root.currentName = focusedName;
|
||||||
|
}
|
||||||
|
root.monitors = built;
|
||||||
|
root.refreshed();
|
||||||
|
}
|
||||||
|
|
||||||
|
function compareOutputs(a: string, b: string): int {
|
||||||
|
const left = root.outputLayout[a] ?? {};
|
||||||
|
const right = root.outputLayout[b] ?? {};
|
||||||
|
const leftKnown = left.known === true;
|
||||||
|
const rightKnown = right.known === true;
|
||||||
|
if (leftKnown !== rightKnown)
|
||||||
|
return leftKnown ? -1 : 1;
|
||||||
|
const yDelta = root.asNumber(left.y, 0) - root.asNumber(right.y, 0);
|
||||||
|
if (yDelta !== 0)
|
||||||
|
return yDelta;
|
||||||
|
const xDelta = root.asNumber(left.x, 0) - root.asNumber(right.x, 0);
|
||||||
|
if (xDelta !== 0)
|
||||||
|
return xDelta;
|
||||||
|
if (a < b)
|
||||||
|
return -1;
|
||||||
|
if (a > b)
|
||||||
|
return 1;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Niri indexes count on the focused monitor only, so focus that monitor
|
||||||
|
// first, then the index. Hyprland switches by workspace id in one command.
|
||||||
|
function focusWorkspace(output: string, idx: int, id: int): void {
|
||||||
|
if (root.kind === "niri") {
|
||||||
|
const commands = [];
|
||||||
|
if (output.length > 0)
|
||||||
|
commands.push(["niri", "msg", "action", "focus-monitor", output]);
|
||||||
|
commands.push(["niri", "msg", "action", "focus-workspace", String(idx)]);
|
||||||
|
root.focusQueue = commands;
|
||||||
|
} else if (root.kind === "hyprland") {
|
||||||
|
if (id < 0)
|
||||||
|
return;
|
||||||
|
root.focusQueue = [["hyprctl", "dispatch", "workspace", String(id)]];
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.pumpFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pumpFocus(): void {
|
||||||
|
if (root.focusQueue.length === 0)
|
||||||
|
return;
|
||||||
|
const next = root.focusQueue[0];
|
||||||
|
root.focusQueue = root.focusQueue.slice(1);
|
||||||
|
if (focusProc.running) {
|
||||||
|
root.focusPending = next;
|
||||||
|
root.focusRestart = true;
|
||||||
|
focusProc.running = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
focusProc.command = next;
|
||||||
|
focusProc.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterFocusExit(): void {
|
||||||
|
if (root.focusRestart) {
|
||||||
|
root.focusRestart = false;
|
||||||
|
focusProc.command = root.focusPending;
|
||||||
|
focusProc.running = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.pumpFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: query
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
if (!root.acceptStream)
|
||||||
|
return;
|
||||||
|
root.acceptStream = false;
|
||||||
|
|
||||||
|
let parsed = null;
|
||||||
|
try {
|
||||||
|
parsed = JSON.parse(this.text);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("workspace-manager: could not read workspace data:", e);
|
||||||
|
if (root.queryStage === "outputs" || root.queryStage === "monitors") {
|
||||||
|
root.outputLayout = ({ });
|
||||||
|
root.startStage("workspaces");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (root.queryStage === "windows") {
|
||||||
|
console.warn("workspace-manager: could not read window data, continuing without windows");
|
||||||
|
root.windowList = [];
|
||||||
|
root.buildMonitors(root.workspaceData);
|
||||||
|
root.finishQuery();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.finishQuery();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.queryStage === "outputs") {
|
||||||
|
root.parseOutputs(parsed);
|
||||||
|
root.startStage("workspaces");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (root.queryStage === "monitors") {
|
||||||
|
root.parseMonitors(parsed);
|
||||||
|
root.startStage("workspaces");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (root.queryStage === "workspaces") {
|
||||||
|
root.workspaceData = parsed;
|
||||||
|
root.startStage("windows");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.parseWindows(parsed);
|
||||||
|
root.buildMonitors(root.workspaceData);
|
||||||
|
root.finishQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: action
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stderr: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
if (this.text.trim().length > 0)
|
||||||
|
console.warn("workspace-manager:", this.text.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: focusProc
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: root.afterFocusExit()
|
||||||
|
|
||||||
|
stderr: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
if (this.text.trim().length > 0)
|
||||||
|
console.warn("workspace-manager:", this.text.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,304 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Wayland
|
||||||
|
|
||||||
|
PanelWindow {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property bool shellOpen
|
||||||
|
required property Compositor compositor
|
||||||
|
required property Theme theme
|
||||||
|
|
||||||
|
// Enter, or a click on a card: the workspace was chosen.
|
||||||
|
signal requestClose
|
||||||
|
// Escape, or a click on the backdrop: leave without switching.
|
||||||
|
signal requestBack
|
||||||
|
|
||||||
|
visible: root.shellOpen
|
||||||
|
color: "transparent"
|
||||||
|
|
||||||
|
exclusionMode: ExclusionMode.Ignore
|
||||||
|
WlrLayershell.namespace: "quickshell:workspace-manager-goto"
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
bottom: true
|
||||||
|
}
|
||||||
|
|
||||||
|
property int monitorIndex: 0
|
||||||
|
// One selected workspace index per monitor. Reassigned as a whole so
|
||||||
|
// the carousel notices the change. Parallel to compositor.monitors.
|
||||||
|
property var workspaceIndices: []
|
||||||
|
property bool seedPending: false
|
||||||
|
property bool animate: false
|
||||||
|
|
||||||
|
function workspaceIndexAt(index: int): int {
|
||||||
|
const list = root.workspaceIndices;
|
||||||
|
if (!list || index < 0 || index >= list.length)
|
||||||
|
return 0;
|
||||||
|
const value = list[index];
|
||||||
|
if (value === undefined || value === null)
|
||||||
|
return 0;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function seedSelection(): void {
|
||||||
|
const mons = root.compositor.monitors ?? [];
|
||||||
|
const indices = [];
|
||||||
|
let focusedMonitor = 0;
|
||||||
|
for (let i = 0; i < mons.length; i++) {
|
||||||
|
const workspaces = mons[i].workspaces ?? [];
|
||||||
|
let activeIndex = 0;
|
||||||
|
let focusedIndex = -1;
|
||||||
|
for (let j = 0; j < workspaces.length; j++) {
|
||||||
|
if (workspaces[j].active)
|
||||||
|
activeIndex = j;
|
||||||
|
if (workspaces[j].focused) {
|
||||||
|
focusedIndex = j;
|
||||||
|
focusedMonitor = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indices.push(focusedIndex >= 0 ? focusedIndex : activeIndex);
|
||||||
|
}
|
||||||
|
root.monitorIndex = mons.length === 0 ? 0 : focusedMonitor;
|
||||||
|
root.workspaceIndices = indices;
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveWorkspace(delta: int): void {
|
||||||
|
root.animate = true;
|
||||||
|
const mons = root.compositor.monitors ?? [];
|
||||||
|
if (root.monitorIndex < 0 || root.monitorIndex >= mons.length)
|
||||||
|
return;
|
||||||
|
const count = (mons[root.monitorIndex].workspaces ?? []).length;
|
||||||
|
if (count === 0)
|
||||||
|
return;
|
||||||
|
const current = root.workspaceIndexAt(root.monitorIndex);
|
||||||
|
const next = (current + delta + count) % count;
|
||||||
|
const copy = root.workspaceIndices.slice();
|
||||||
|
while (copy.length <= root.monitorIndex)
|
||||||
|
copy.push(0);
|
||||||
|
copy[root.monitorIndex] = next;
|
||||||
|
root.workspaceIndices = copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveMonitor(delta: int): void {
|
||||||
|
root.animate = true;
|
||||||
|
const count = (root.compositor.monitors ?? []).length;
|
||||||
|
if (count === 0)
|
||||||
|
return;
|
||||||
|
const next = root.monitorIndex + delta;
|
||||||
|
if (next < 0 || next >= count)
|
||||||
|
return;
|
||||||
|
root.monitorIndex = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateAt(monitorAt: int, workspaceAt: int): void {
|
||||||
|
const mons = root.compositor.monitors ?? [];
|
||||||
|
if (monitorAt < 0 || monitorAt >= mons.length) {
|
||||||
|
root.requestClose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const workspaces = mons[monitorAt].workspaces ?? [];
|
||||||
|
if (workspaceAt < 0 || workspaceAt >= workspaces.length) {
|
||||||
|
root.requestClose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ws = workspaces[workspaceAt];
|
||||||
|
root.compositor.focusWorkspace(root.compositor.asString(mons[monitorAt].name), ws.idx, ws.id);
|
||||||
|
root.requestClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateSelection(): void {
|
||||||
|
root.activateAt(root.monitorIndex, root.workspaceIndexAt(root.monitorIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
root.animate = false;
|
||||||
|
if (!root.visible) {
|
||||||
|
root.seedPending = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.seedPending = true;
|
||||||
|
root.compositor.refresh();
|
||||||
|
Qt.callLater(() => focusScope.forceActiveFocus());
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.compositor
|
||||||
|
|
||||||
|
function onRefreshed(): void {
|
||||||
|
if (!root.visible || !root.seedPending)
|
||||||
|
return;
|
||||||
|
// This read is stale. Keep waiting for the one already queued.
|
||||||
|
if (root.compositor.refreshQueued)
|
||||||
|
return;
|
||||||
|
root.seedPending = false;
|
||||||
|
root.seedSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: root.theme.backdrop
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: root.requestBack()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FocusScope {
|
||||||
|
id: focusScope
|
||||||
|
anchors.fill: parent
|
||||||
|
focus: root.visible
|
||||||
|
|
||||||
|
Keys.onPressed: event => {
|
||||||
|
switch (event.key) {
|
||||||
|
case Qt.Key_Left:
|
||||||
|
root.moveWorkspace(-1);
|
||||||
|
break;
|
||||||
|
case Qt.Key_Right:
|
||||||
|
root.moveWorkspace(1);
|
||||||
|
break;
|
||||||
|
case Qt.Key_Up:
|
||||||
|
root.moveMonitor(-1);
|
||||||
|
break;
|
||||||
|
case Qt.Key_Down:
|
||||||
|
root.moveMonitor(1);
|
||||||
|
break;
|
||||||
|
case Qt.Key_Return:
|
||||||
|
case Qt.Key_Enter:
|
||||||
|
root.activateSelection();
|
||||||
|
break;
|
||||||
|
case Qt.Key_Escape:
|
||||||
|
root.requestBack();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
WheelHandler {
|
||||||
|
id: swipeHandler
|
||||||
|
target: focusScope
|
||||||
|
property real accX: 0
|
||||||
|
property real accY: 0
|
||||||
|
|
||||||
|
function stepWorkspace(delta: int): void {
|
||||||
|
root.moveWorkspace(delta);
|
||||||
|
swipeHandler.accX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stepMonitor(delta: int): void {
|
||||||
|
root.moveMonitor(delta);
|
||||||
|
swipeHandler.accY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
onWheel: event => {
|
||||||
|
const px = event.pixelDelta;
|
||||||
|
const ang = event.angleDelta;
|
||||||
|
const dx = px.x !== 0 ? px.x : ang.x;
|
||||||
|
const dy = px.y !== 0 ? px.y : ang.y;
|
||||||
|
if (Math.abs(dy) >= Math.abs(dx)) {
|
||||||
|
swipeHandler.accY += dy;
|
||||||
|
if (swipeHandler.accY <= -root.theme.swipeThreshold)
|
||||||
|
swipeHandler.stepMonitor(1);
|
||||||
|
else if (swipeHandler.accY >= root.theme.swipeThreshold)
|
||||||
|
swipeHandler.stepMonitor(-1);
|
||||||
|
} else {
|
||||||
|
swipeHandler.accX += dx;
|
||||||
|
if (swipeHandler.accX <= -root.theme.swipeThreshold)
|
||||||
|
swipeHandler.stepWorkspace(1);
|
||||||
|
else if (swipeHandler.accX >= root.theme.swipeThreshold)
|
||||||
|
swipeHandler.stepWorkspace(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root.compositor.monitors
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: row
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
|
||||||
|
// Each row centers its own workspace. Rows are not lined up
|
||||||
|
// in columns across monitors.
|
||||||
|
readonly property int rowIndex: index
|
||||||
|
readonly property int selectedWs: root.workspaceIndexAt(rowIndex)
|
||||||
|
readonly property var workspaces: modelData.workspaces ?? []
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
height: root.theme.cardHeight
|
||||||
|
z: row.rowIndex === root.monitorIndex ? 1 : 0
|
||||||
|
opacity: 1 - Math.min(Math.abs(row.rowIndex - root.monitorIndex) * root.theme.carouselRowFadeStep, root.theme.carouselRowMaxFade)
|
||||||
|
anchors.verticalCenterOffset: (row.rowIndex - root.monitorIndex) * root.theme.carouselStepY
|
||||||
|
|
||||||
|
Behavior on anchors.verticalCenterOffset {
|
||||||
|
enabled: root.animate
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.theme.carouselDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on opacity {
|
||||||
|
enabled: root.animate
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.theme.carouselDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
width: root.theme.cardWidth * 2
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.top
|
||||||
|
anchors.bottomMargin: root.theme.monitorLabelGap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
elide: Text.ElideMiddle
|
||||||
|
color: root.theme.labelColor
|
||||||
|
font.pixelSize: root.theme.monitorLabelSize
|
||||||
|
text: row.modelData.name.length > 0 ? row.modelData.name : "screen"
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: row.workspaces
|
||||||
|
|
||||||
|
WorkspaceCard {
|
||||||
|
id: card
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
|
||||||
|
readonly property int distance: Math.abs(index - row.selectedWs)
|
||||||
|
|
||||||
|
theme: root.theme
|
||||||
|
workspaceName: modelData.name
|
||||||
|
workspaceIndex: modelData.idx
|
||||||
|
selected: row.rowIndex === root.monitorIndex && index === row.selectedWs
|
||||||
|
current: modelData.focused === true
|
||||||
|
animateMoves: root.animate
|
||||||
|
windows: modelData.windows ?? []
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.horizontalCenterOffset: (index - row.selectedWs) * root.theme.carouselStepX
|
||||||
|
opacity: 1 - Math.min(card.distance * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||||
|
scale: 1 - Math.min(card.distance * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||||
|
z: card.selected ? 1 : 0
|
||||||
|
|
||||||
|
onActivated: root.activateAt(row.rowIndex, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ PanelWindow {
|
|||||||
required property Theme theme
|
required property Theme theme
|
||||||
|
|
||||||
signal requestClose
|
signal requestClose
|
||||||
|
signal requestGoto
|
||||||
|
|
||||||
visible: root.shellOpen
|
visible: root.shellOpen
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
@@ -18,7 +19,7 @@ PanelWindow {
|
|||||||
implicitHeight: root.theme.barHeight
|
implicitHeight: root.theme.barHeight
|
||||||
|
|
||||||
exclusionMode: ExclusionMode.Ignore
|
exclusionMode: ExclusionMode.Ignore
|
||||||
WlrLayershell.namespace: "quickshell:workspace-rename"
|
WlrLayershell.namespace: "quickshell:workspace-manager"
|
||||||
WlrLayershell.layer: WlrLayer.Overlay
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||||
|
|
||||||
@@ -51,6 +52,12 @@ PanelWindow {
|
|||||||
root.requestClose();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: root.theme.cornerRadius
|
radius: root.theme.cornerRadius
|
||||||
@@ -115,6 +122,21 @@ PanelWindow {
|
|||||||
root.requestClose();
|
root.requestClose();
|
||||||
event.accepted = true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import QtQuick
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
readonly property color barBg: "#f00b0e14"
|
||||||
|
readonly property color barBorder: "#40ffffff"
|
||||||
|
readonly property color textColor: "#ffffff"
|
||||||
|
readonly property color labelColor: "#a9b1d6"
|
||||||
|
readonly property color fieldBg: "#332a2e3a"
|
||||||
|
readonly property color fieldBorder: "#7aa2f7"
|
||||||
|
readonly property color buttonBg: "#7aa2f7"
|
||||||
|
readonly property color buttonText: "#0b0e14"
|
||||||
|
|
||||||
|
readonly property real cornerRadius: 12
|
||||||
|
readonly property real barHeight: 84
|
||||||
|
readonly property real barWidth: 800
|
||||||
|
// Space between the bar edge and the boxes inside it.
|
||||||
|
readonly property real barPadding: 18
|
||||||
|
readonly property real barSpacing: 14
|
||||||
|
// Space between a box edge and its own text.
|
||||||
|
readonly property real fieldPadding: 14
|
||||||
|
readonly property real logoSize: 36
|
||||||
|
readonly property real fontSize: 24
|
||||||
|
readonly property real buttonWidth: 86
|
||||||
|
|
||||||
|
// Fullscreen dim behind the workspace carousel.
|
||||||
|
readonly property color backdrop: "#cc0b0e14"
|
||||||
|
|
||||||
|
readonly property real cardWidth: 280
|
||||||
|
readonly property real cardHeight: 160
|
||||||
|
readonly property real cardSpacing: 36
|
||||||
|
readonly property real cardRadius: 16
|
||||||
|
readonly property real monitorLabelSize: 18
|
||||||
|
readonly property real monitorLabelGap: 12
|
||||||
|
|
||||||
|
// One step across a monitor's workspaces, and one step between monitors.
|
||||||
|
// The gap above a card leaves room for that monitor's name.
|
||||||
|
readonly property real carouselStepX: cardWidth + cardSpacing
|
||||||
|
readonly property real carouselStepY: cardHeight + 110
|
||||||
|
readonly property real carouselFadeStep: 0.35
|
||||||
|
readonly property real carouselMaxFade: 0.85
|
||||||
|
readonly property real carouselScaleStep: 0.08
|
||||||
|
readonly property real carouselMaxScaleReduction: 0.3
|
||||||
|
readonly property real carouselRowFadeStep: 0.4
|
||||||
|
readonly property real carouselRowMaxFade: 0.72
|
||||||
|
readonly property int carouselDuration: 220
|
||||||
|
|
||||||
|
// A swipe must cross this many pixels (or angleDelta units) before the
|
||||||
|
// selection steps once.
|
||||||
|
readonly property int swipeThreshold: 120
|
||||||
|
|
||||||
|
// Window bubbles inside a workspace card.
|
||||||
|
readonly property real windowIconSize: 20
|
||||||
|
readonly property real windowFontSize: 16
|
||||||
|
readonly property real windowRowSpacing: 6
|
||||||
|
readonly property int maxWindowRows: 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property Theme theme
|
||||||
|
required property string workspaceName
|
||||||
|
required property int workspaceIndex
|
||||||
|
required property bool selected
|
||||||
|
required property bool current
|
||||||
|
required property bool animateMoves
|
||||||
|
required property var windows
|
||||||
|
|
||||||
|
signal activated
|
||||||
|
|
||||||
|
// Windows that fit before the "+N more" overflow.
|
||||||
|
readonly property var displayWindows: root.windows.slice(0, root.theme.maxWindowRows)
|
||||||
|
readonly property int hiddenCount: Math.max(0, root.windows.length - root.theme.maxWindowRows)
|
||||||
|
|
||||||
|
width: root.theme.cardWidth
|
||||||
|
height: root.theme.cardHeight
|
||||||
|
radius: root.theme.cardRadius
|
||||||
|
color: root.theme.fieldBg
|
||||||
|
border.width: root.selected ? 3 : 1
|
||||||
|
border.color: root.selected ? root.theme.fieldBorder : root.theme.barBorder
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Behavior on anchors.horizontalCenterOffset {
|
||||||
|
enabled: root.animateMoves
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.theme.carouselDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on opacity {
|
||||||
|
enabled: root.animateMoves
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.theme.carouselDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on scale {
|
||||||
|
enabled: root.animateMoves
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.theme.carouselDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: root.theme.fieldPadding
|
||||||
|
spacing: 6
|
||||||
|
|
||||||
|
// Top row: workspace name + index + current badge
|
||||||
|
RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 6
|
||||||
|
|
||||||
|
Text {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: root.theme.textColor
|
||||||
|
font.pixelSize: root.theme.fontSize
|
||||||
|
text: root.workspaceName.length > 0 ? root.workspaceName : String(root.workspaceIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
visible: root.workspaceName.length > 0
|
||||||
|
color: root.theme.labelColor
|
||||||
|
font.pixelSize: root.theme.monitorLabelSize
|
||||||
|
text: String(root.workspaceIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
visible: root.current
|
||||||
|
color: root.theme.fieldBorder
|
||||||
|
font.pixelSize: root.theme.monitorLabelSize
|
||||||
|
text: "current"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Window bubbles
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: root.theme.windowRowSpacing
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root.displayWindows
|
||||||
|
|
||||||
|
Row {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 6
|
||||||
|
|
||||||
|
Image {
|
||||||
|
width: root.theme.windowIconSize
|
||||||
|
height: root.theme.windowIconSize
|
||||||
|
source: Quickshell.iconPath(modelData.app.length > 0 ? modelData.app : "window")
|
||||||
|
sourceSize.width: root.theme.windowIconSize * 2
|
||||||
|
sourceSize.height: root.theme.windowIconSize * 2
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
smooth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
width: parent.width - root.theme.windowIconSize - parent.spacing
|
||||||
|
height: root.theme.windowIconSize
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: root.theme.labelColor
|
||||||
|
font.pixelSize: root.theme.windowFontSize
|
||||||
|
text: modelData.title.length > 0 ? modelData.title : "Untitled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
visible: root.hiddenCount > 0
|
||||||
|
color: root.theme.labelColor
|
||||||
|
font.pixelSize: root.theme.windowFontSize
|
||||||
|
text: "+" + root.hiddenCount + " more"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: root.activated()
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
File renamed without changes.
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
@@ -0,0 +1,76 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
ShellRoot {
|
||||||
|
id: shell
|
||||||
|
|
||||||
|
// "", "rename", or "goto".
|
||||||
|
property string mode: ""
|
||||||
|
// Set only when Ctrl+G opens the carousel from the rename bar.
|
||||||
|
property bool gotoReturnsToRename: false
|
||||||
|
|
||||||
|
Compositor {
|
||||||
|
id: compositor
|
||||||
|
}
|
||||||
|
|
||||||
|
Theme {
|
||||||
|
id: theme
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (compositor.kind === "")
|
||||||
|
console.warn("workspace-manager: neither niri nor Hyprland was detected");
|
||||||
|
}
|
||||||
|
|
||||||
|
function openGoto(returnToRename: bool): void {
|
||||||
|
shell.gotoReturnsToRename = returnToRename;
|
||||||
|
shell.mode = "goto";
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeAll(): void {
|
||||||
|
shell.mode = "";
|
||||||
|
shell.gotoReturnsToRename = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "workspace"
|
||||||
|
|
||||||
|
function toggle(): void {
|
||||||
|
if (shell.mode === "")
|
||||||
|
shell.mode = "rename";
|
||||||
|
else
|
||||||
|
shell.closeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// "goto" is a reserved word, so the IPC name is goTo.
|
||||||
|
function goTo(): void {
|
||||||
|
if (shell.mode === "goto")
|
||||||
|
shell.closeAll();
|
||||||
|
else
|
||||||
|
shell.openGoto(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RenameBar {
|
||||||
|
shellOpen: shell.mode === "rename"
|
||||||
|
compositor: compositor
|
||||||
|
theme: theme
|
||||||
|
onRequestClose: shell.closeAll()
|
||||||
|
onRequestGoto: shell.openGoto(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
GotoView {
|
||||||
|
shellOpen: shell.mode === "goto"
|
||||||
|
compositor: compositor
|
||||||
|
theme: theme
|
||||||
|
onRequestClose: shell.closeAll()
|
||||||
|
onRequestBack: {
|
||||||
|
if (shell.gotoReturnsToRename)
|
||||||
|
shell.mode = "rename";
|
||||||
|
else
|
||||||
|
shell.mode = "";
|
||||||
|
shell.gotoReturnsToRename = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Io
|
|
||||||
|
|
||||||
// Talks to whichever compositor is running. Everything goes through the
|
|
||||||
// command line tools so this file works the same on niri and Hyprland.
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
// "niri", "hyprland" or "" when neither was detected.
|
|
||||||
readonly property string kind: {
|
|
||||||
if (Quickshell.env("NIRI_SOCKET"))
|
|
||||||
return "niri";
|
|
||||||
if (Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE"))
|
|
||||||
return "hyprland";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property string logoSource: {
|
|
||||||
if (root.kind === "niri")
|
|
||||||
return Qt.resolvedUrl("assets/niri.png");
|
|
||||||
if (root.kind === "hyprland")
|
|
||||||
return Qt.resolvedUrl("assets/hyprland.png");
|
|
||||||
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
|
|
||||||
|
|
||||||
signal refreshed
|
|
||||||
|
|
||||||
function refresh(): void {
|
|
||||||
if (root.kind === "")
|
|
||||||
return;
|
|
||||||
query.running = false;
|
|
||||||
query.command = root.kind === "niri" ? ["niri", "msg", "--json", "workspaces"] : ["hyprctl", "-j", "activeworkspace"];
|
|
||||||
query.running = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: query
|
|
||||||
running: false
|
|
||||||
|
|
||||||
stdout: StdioCollector {
|
|
||||||
onStreamFinished: {
|
|
||||||
let parsed = null;
|
|
||||||
try {
|
|
||||||
parsed = JSON.parse(this.text);
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("workspace-rename: could not read workspace data:", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.kind === "niri") {
|
|
||||||
const focused = (parsed ?? []).find(ws => ws.is_focused);
|
|
||||||
if (!focused) {
|
|
||||||
console.warn("workspace-rename: no focused workspace reported");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
root.currentId = focused.id ?? -1;
|
|
||||||
root.currentName = focused.name ?? "";
|
|
||||||
} else {
|
|
||||||
root.currentId = parsed.id ?? -1;
|
|
||||||
// Unnamed Hyprland workspaces report their id as the name.
|
|
||||||
const name = String(parsed.name ?? "");
|
|
||||||
root.currentName = name === String(root.currentId) ? "" : name;
|
|
||||||
}
|
|
||||||
root.refreshed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: action
|
|
||||||
running: false
|
|
||||||
|
|
||||||
stderr: StdioCollector {
|
|
||||||
onStreamFinished: {
|
|
||||||
if (this.text.trim().length > 0)
|
|
||||||
console.warn("workspace-rename:", this.text.trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
readonly property color barBg: "#f00b0e14"
|
|
||||||
readonly property color barBorder: "#40ffffff"
|
|
||||||
readonly property color textColor: "#ffffff"
|
|
||||||
readonly property color labelColor: "#a9b1d6"
|
|
||||||
readonly property color fieldBg: "#332a2e3a"
|
|
||||||
readonly property color fieldBorder: "#7aa2f7"
|
|
||||||
readonly property color buttonBg: "#7aa2f7"
|
|
||||||
readonly property color buttonText: "#0b0e14"
|
|
||||||
|
|
||||||
readonly property real cornerRadius: 12
|
|
||||||
readonly property real barHeight: 84
|
|
||||||
readonly property real barWidth: 800
|
|
||||||
// Space between the bar edge and the boxes inside it.
|
|
||||||
readonly property real barPadding: 18
|
|
||||||
readonly property real barSpacing: 14
|
|
||||||
// Space between a box edge and its own text.
|
|
||||||
readonly property real fieldPadding: 14
|
|
||||||
readonly property real logoSize: 36
|
|
||||||
readonly property real fontSize: 24
|
|
||||||
readonly property real buttonWidth: 86
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Io
|
|
||||||
|
|
||||||
ShellRoot {
|
|
||||||
id: shell
|
|
||||||
|
|
||||||
property bool barOpen: false
|
|
||||||
|
|
||||||
Compositor {
|
|
||||||
id: compositor
|
|
||||||
}
|
|
||||||
|
|
||||||
Theme {
|
|
||||||
id: theme
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
if (compositor.kind === "")
|
|
||||||
console.warn("workspace-rename: neither niri nor Hyprland was detected");
|
|
||||||
}
|
|
||||||
|
|
||||||
IpcHandler {
|
|
||||||
target: "wsname"
|
|
||||||
|
|
||||||
function toggle(): void {
|
|
||||||
shell.barOpen = !shell.barOpen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RenameBar {
|
|
||||||
shellOpen: shell.barOpen
|
|
||||||
compositor: compositor
|
|
||||||
theme: theme
|
|
||||||
onRequestClose: shell.barOpen = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user