init: working version
This commit is contained in:
commit
7d8d7dacae
109 changed files with 15066 additions and 0 deletions
145
modules/Commands.qml
Normal file
145
modules/Commands.qml
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
import qs.config
|
||||
import qs.custom
|
||||
import qs.services
|
||||
import qs.util
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
// Workspace Handling
|
||||
|
||||
function allWorkspaces(): list<int> {
|
||||
let ids = [];
|
||||
States.screens.forEach((uiState, _, _) => {
|
||||
for (let i = 0; i < uiState.workspaces.count; i++) {
|
||||
ids.push(uiState.workspaces.get(i).workspace.id);
|
||||
}
|
||||
})
|
||||
return ids;
|
||||
}
|
||||
|
||||
function nextWorkspace(): int {
|
||||
let id = 1;
|
||||
const ws = allWorkspaces();
|
||||
while (ws.includes(id)) id++;
|
||||
return id;
|
||||
}
|
||||
|
||||
// Workspace Commands
|
||||
|
||||
function newWorkspace(): void {
|
||||
Hypr.dispatch(`focusworkspaceoncurrentmonitor ${nextWorkspace()}`);
|
||||
}
|
||||
|
||||
CustomShortcut {
|
||||
name: "newWorkspace"
|
||||
description: "Go to a new workspace"
|
||||
onPressed: root.newWorkspace();
|
||||
}
|
||||
Timer {
|
||||
id: newWorkspaceTimer
|
||||
running: false
|
||||
interval: Hypr.arbitraryRaceConditionDelay
|
||||
onTriggered: {
|
||||
const uiState = States.getForActive();
|
||||
const workspace = Hypr.focusedWorkspace;
|
||||
// Add workspace if not already added during delay
|
||||
let found = false;
|
||||
for (let i = 0; i < uiState.workspaces.count; i++) {
|
||||
if (uiState.workspaces.get(i).workspace.id === workspace.id)
|
||||
found = true;
|
||||
}
|
||||
if (!found)
|
||||
uiState.workspaces.append({"workspace": workspace});
|
||||
}
|
||||
}
|
||||
|
||||
function goToWorkspace(index: int): void {
|
||||
const uiState = States.getForActive();
|
||||
if (index > uiState.workspaces.count) return;
|
||||
let id;
|
||||
if (index === uiState.workspaces.count) {
|
||||
id = root.nextWorkspace();
|
||||
} else {
|
||||
id = uiState.workspaces.get(index).workspace.id;
|
||||
}
|
||||
Hypr.dispatch(`workspace ${id}`);
|
||||
}
|
||||
|
||||
Instantiator {
|
||||
model: [...Array(10).keys()]
|
||||
delegate: CustomShortcut {
|
||||
required property int modelData
|
||||
name: `workspace${modelData + 1}`
|
||||
description: `Go to workspace ${modelData + 1}`
|
||||
onPressed: root.goToWorkspace(modelData)
|
||||
}
|
||||
}
|
||||
|
||||
function moveToWorkspace(index: int): void {
|
||||
const uiState = States.getForActive();
|
||||
if (index > uiState.workspaces.count) return;
|
||||
let id;
|
||||
if (index === uiState.workspaces.count) {
|
||||
id = nextWorkspace();
|
||||
} else {
|
||||
id = uiState.workspaces.get(index).workspace.id;
|
||||
}
|
||||
Hypr.dispatch(`movetoworkspace ${id}`);
|
||||
}
|
||||
|
||||
Instantiator {
|
||||
model: [...Array(10).keys()]
|
||||
delegate: CustomShortcut {
|
||||
required property int modelData
|
||||
name: `movetoworkspace${modelData + 1}`
|
||||
description: `Move the focused window to workspace ${modelData + 1}`
|
||||
onPressed: root.moveToWorkspace(modelData)
|
||||
}
|
||||
}
|
||||
|
||||
// Panels
|
||||
|
||||
CustomShortcut {
|
||||
name: "dashboard"
|
||||
description: "Toggle dashboard"
|
||||
onPressed: {
|
||||
const uiState = States.getForActive();
|
||||
uiState.dashboard = !uiState.dashboard;
|
||||
}
|
||||
}
|
||||
|
||||
CustomShortcut {
|
||||
name: "launcher"
|
||||
description: "Toggle launcher"
|
||||
onPressed: {
|
||||
const uiState = States.getForActive();
|
||||
uiState.laucher = !uiState.launcher;
|
||||
}
|
||||
}
|
||||
|
||||
CustomShortcut {
|
||||
name: "session"
|
||||
description: "Toggle session menu"
|
||||
onPressed: {
|
||||
const uiState = States.getForActive();
|
||||
uiState.session = !uiState.session;
|
||||
}
|
||||
}
|
||||
|
||||
CustomShortcut {
|
||||
name: "escape"
|
||||
description: "Close every panel"
|
||||
onPressed: {
|
||||
States.screens.forEach((uiState, _, _) => {
|
||||
uiState.dashboard = false;
|
||||
uiState.launcher = false;
|
||||
uiState.osd = false;
|
||||
uiState.session = false;
|
||||
uiState.blockScreen = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue