quickshell overview starting work
This commit is contained in:
1 parent
3c86efa4ff
commit
fdca7d8d9d
21 files changed
+580
-272
No files matched your search
@@ -0,0 +1,71 @@
|
||||
# configs/fwbook/quickshell/
|
||||
|
||||
Host-specific Quickshell configs for `fwbook`. Symlinked to `~/.config/quickshell`
|
||||
by the `skyg.nixos.desktop.tiler.quickshell` module, which defaults its
|
||||
`configName` to the machine hostName (`configs/${hostName}/quickshell`).
|
||||
|
||||
Quickshell resolves each subdirectory as an independently named config, run
|
||||
via `qs -c <name>` (or `qs -p <path>` for direct path testing without the
|
||||
symlink). This is deliberately not part of noctalia/DMS — each `qs -c <name>`
|
||||
here is its own standalone process/shell.
|
||||
|
||||
## overview/
|
||||
|
||||
A niri-like scrolling overview for Hyprland, standing in for a native overview
|
||||
plugin (Hyprland has none maintained against tagged releases — see
|
||||
`modules/nixos/desktop/tiler/ABOUTME.md`).
|
||||
|
||||
- **Model:** the current monitor's workspaces are vertical rows, each row a
|
||||
horizontal strip of that workspace's windows (columns), sorted by x-position
|
||||
to match the Hyprland `scrolling` layout's tape order.
|
||||
- **Controls:** Arrow keys move the selection (Left/Right = window in the row,
|
||||
Up/Down = workspace row), Enter focuses the selection and closes, Esc
|
||||
cancels. No mouse-driven drag/resize.
|
||||
- **Previews:** live via `Quickshell.Wayland.ScreencopyView`, capturing each
|
||||
window's `HyprlandToplevel.wayland` handle. Capture only runs while the
|
||||
overview is visible (`live` is bound to the window's visibility).
|
||||
- **Focus dispatch:** classic `hyprctl`-style dispatcher strings
|
||||
(`"workspace " + id`, `"focuswindow address:" + addr`) via
|
||||
`Hyprland.dispatch(...)` — these work regardless of whether Hyprland's
|
||||
config is Lua or hyprlang, unlike the Lua-eval dispatch form.
|
||||
|
||||
### Files
|
||||
|
||||
```
|
||||
overview/
|
||||
├── shell.qml # ShellRoot: IpcHandler (target "overview": toggle/open/close)
|
||||
│ # + Variants { model: Quickshell.screens } instantiating one
|
||||
│ # OverviewWindow per monitor
|
||||
├── OverviewWindow.qml # per-monitor PanelWindow (layer-shell overlay); builds the
|
||||
│ # workspace/window model from Quickshell.Hyprland, owns
|
||||
│ # selection state, key handling, and HyprlandFocusGrab
|
||||
├── WorkspaceRow.qml # one workspace = horizontal Row of WindowCards + label
|
||||
├── WindowCard.qml # live ScreencopyView preview + icon/title footer + selection ring
|
||||
└── Theme.qml # plain QtObject with colors/sizes, instantiated once per
|
||||
# OverviewWindow and prop-drilled down (no singleton/qmldir)
|
||||
```
|
||||
|
||||
`Theme.qml` and the other sibling `.qml` files are used without explicit
|
||||
imports — Quickshell (like plain QML) makes same-directory files visible as
|
||||
types automatically, no `qmldir` needed for single-directory configs like this
|
||||
one.
|
||||
|
||||
### Wiring (Hyprland side, `configs/fwbook/hypr/`)
|
||||
|
||||
- `conf/keybindings.lua` — `Mod+Tab` runs `qs -c overview ipc call overview toggle`
|
||||
- `conf/inputs.lua` — 4-finger swipe up/down open/close it (discrete gesture,
|
||||
no swipe-progress animation)
|
||||
- `conf/autostart.lua` — the daemon is started via
|
||||
`setpriv --ambient-caps -all -- qs -c overview` (D-Bus calls in
|
||||
quickshell-based apps fail silently without this wrapper under this
|
||||
Hyprland/UWSM setup)
|
||||
|
||||
### Testing without a rebuild
|
||||
|
||||
Since `~/.config/quickshell` is a symlink into this repo, edits are live.
|
||||
Test directly by path before relying on the installed symlink:
|
||||
|
||||
```
|
||||
qs -p ~/nixos-setup/configs/fwbook/quickshell/overview
|
||||
qs -p ~/nixos-setup/configs/fwbook/quickshell/overview ipc call overview toggle
|
||||
```
|
||||
@@ -0,0 +1,188 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
|
||||
required property bool shellOpen
|
||||
signal requestClose()
|
||||
|
||||
readonly property var monitor: Hyprland.monitorFor(root.screen)
|
||||
readonly property bool monitorFocused: monitor && Hyprland.focusedMonitor && monitor.id === Hyprland.focusedMonitor.id
|
||||
visible: root.shellOpen && root.monitorFocused
|
||||
|
||||
color: "transparent"
|
||||
|
||||
WlrLayershell.namespace: "quickshell:overview"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
property Theme theme: Theme {}
|
||||
|
||||
// Sorts a workspace's toplevels by x-position so card order matches the
|
||||
// scrolling layout's column order.
|
||||
function sortedToplevels(ws) {
|
||||
const list = (ws && ws.toplevels) ? ws.toplevels.values.slice() : [];
|
||||
return list.sort((a, b) => {
|
||||
const ax = a?.lastIpcObject?.at?.[0] ?? 0;
|
||||
const bx = b?.lastIpcObject?.at?.[0] ?? 0;
|
||||
return ax - bx;
|
||||
});
|
||||
}
|
||||
|
||||
// Workspace rows for this monitor, top-to-bottom by workspace id. Special
|
||||
// (scratchpad) workspaces have negative ids and are excluded.
|
||||
readonly property var rows: {
|
||||
const mon = root.monitor;
|
||||
if (!mon || !Hyprland.workspaces) return [];
|
||||
const workspaces = Hyprland.workspaces.values
|
||||
.filter(ws => ws && ws.id > 0 && ws.monitor && ws.monitor.name === mon.name)
|
||||
.sort((a, b) => a.id - b.id);
|
||||
return workspaces.map(ws => ({ workspace: ws, toplevels: root.sortedToplevels(ws) }));
|
||||
}
|
||||
|
||||
property int selectedRow: 0
|
||||
property int selectedCol: 0
|
||||
|
||||
function clampSelection() {
|
||||
if (root.rows.length === 0) {
|
||||
root.selectedRow = 0;
|
||||
root.selectedCol = 0;
|
||||
return;
|
||||
}
|
||||
if (root.selectedRow >= root.rows.length) root.selectedRow = root.rows.length - 1;
|
||||
if (root.selectedRow < 0) root.selectedRow = 0;
|
||||
const count = root.rows[root.selectedRow].toplevels.length;
|
||||
if (root.selectedCol >= count) root.selectedCol = Math.max(0, count - 1);
|
||||
if (root.selectedCol < 0) root.selectedCol = 0;
|
||||
}
|
||||
|
||||
// Reset the selection to the active workspace/window whenever the
|
||||
// overview opens.
|
||||
function resetSelection() {
|
||||
const activeRowIndex = root.rows.findIndex(r => r.workspace.active);
|
||||
root.selectedRow = activeRowIndex >= 0 ? activeRowIndex : 0;
|
||||
const row = root.rows[root.selectedRow];
|
||||
const activeColIndex = row ? row.toplevels.findIndex(tl => tl.activated) : -1;
|
||||
root.selectedCol = activeColIndex >= 0 ? activeColIndex : 0;
|
||||
root.clampSelection();
|
||||
}
|
||||
|
||||
function moveSelection(dRow, dCol) {
|
||||
if (root.rows.length === 0) return;
|
||||
if (dRow !== 0) {
|
||||
root.selectedRow = (root.selectedRow + dRow + root.rows.length) % root.rows.length;
|
||||
root.clampSelection();
|
||||
}
|
||||
if (dCol !== 0) {
|
||||
const count = root.rows[root.selectedRow].toplevels.length;
|
||||
if (count > 0) root.selectedCol = (root.selectedCol + dCol + count) % count;
|
||||
}
|
||||
}
|
||||
|
||||
function activateSelection() {
|
||||
const row = root.rows[root.selectedRow];
|
||||
if (!row) { root.requestClose(); return; }
|
||||
if (!row.workspace.active) Hyprland.dispatch("workspace " + row.workspace.id);
|
||||
const tl = row.toplevels[root.selectedCol];
|
||||
if (tl) Hyprland.dispatch("focuswindow address:" + tl.address);
|
||||
root.requestClose();
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (root.visible) {
|
||||
Hyprland.refreshMonitors();
|
||||
Hyprland.refreshWorkspaces();
|
||||
Hyprland.refreshToplevels();
|
||||
root.resetSelection();
|
||||
Qt.callLater(() => focusScope.forceActiveFocus());
|
||||
}
|
||||
}
|
||||
|
||||
HyprlandFocusGrab {
|
||||
windows: [root]
|
||||
active: root.visible
|
||||
onCleared: {
|
||||
if (root.visible) root.requestClose();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.theme.backdrop
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.requestClose()
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: focusScope
|
||||
anchors.fill: parent
|
||||
focus: root.visible
|
||||
|
||||
Keys.onPressed: event => {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Left:
|
||||
root.moveSelection(0, -1);
|
||||
break;
|
||||
case Qt.Key_Right:
|
||||
root.moveSelection(0, 1);
|
||||
break;
|
||||
case Qt.Key_Up:
|
||||
root.moveSelection(-1, 0);
|
||||
break;
|
||||
case Qt.Key_Down:
|
||||
root.moveSelection(1, 0);
|
||||
break;
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
root.activateSelection();
|
||||
break;
|
||||
case Qt.Key_Escape:
|
||||
root.requestClose();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: root.theme.rowSpacing
|
||||
|
||||
Repeater {
|
||||
model: root.rows
|
||||
|
||||
WorkspaceRow {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
workspace: modelData.workspace
|
||||
toplevels: modelData.toplevels
|
||||
selectedIndex: index === root.selectedRow ? root.selectedCol : -1
|
||||
live: root.visible
|
||||
|
||||
onCardClicked: colIndex => {
|
||||
root.selectedRow = index;
|
||||
root.selectedCol = colIndex;
|
||||
root.activateSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
readonly property color backdrop: "#cc0b0e14"
|
||||
readonly property color cardBg: "#332a2e3a"
|
||||
readonly property color cardBorder: "#40ffffff"
|
||||
readonly property color selectedBorder: "#7aa2f7"
|
||||
readonly property color textColor: "#ffffff"
|
||||
readonly property color emptyTextColor: "#80ffffff"
|
||||
readonly property real cornerRadius: 10
|
||||
readonly property real cardHeight: 180
|
||||
readonly property real cardSpacing: 20
|
||||
readonly property real rowSpacing: 28
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
required property var toplevel
|
||||
required property bool selected
|
||||
required property bool live
|
||||
|
||||
signal activated()
|
||||
|
||||
readonly property var ipc: root.toplevel ? root.toplevel.lastIpcObject : null
|
||||
readonly property real aspect: (ipc && ipc.size && ipc.size[0] > 0 && ipc.size[1] > 0) ? ipc.size[0] / ipc.size[1] : (16 / 9)
|
||||
|
||||
width: Math.min(height * aspect, theme.cardHeight * 2.2)
|
||||
height: theme.cardHeight
|
||||
radius: theme.cornerRadius
|
||||
color: theme.cardBg
|
||||
border.width: selected ? 3 : 1
|
||||
border.color: selected ? theme.selectedBorder : theme.cardBorder
|
||||
clip: true
|
||||
|
||||
ScreencopyView {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 3
|
||||
captureSource: root.live && root.toplevel ? root.toplevel.wayland : null
|
||||
live: root.live
|
||||
paintCursor: false
|
||||
}
|
||||
|
||||
Image {
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 6
|
||||
width: 20
|
||||
height: 20
|
||||
source: Quickshell.iconPath(ipc ? ipc.class : "", "application-x-executable")
|
||||
sourceSize: Qt.size(20, 20)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: title.implicitHeight + 8
|
||||
color: "#99000000"
|
||||
|
||||
Text {
|
||||
id: title
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 30
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
elide: Text.ElideRight
|
||||
color: theme.textColor
|
||||
text: root.toplevel ? root.toplevel.title : ""
|
||||
font.pixelSize: 12
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.activated()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
required property var workspace
|
||||
required property var toplevels
|
||||
required property int selectedIndex
|
||||
required property bool live
|
||||
|
||||
signal cardClicked(int index)
|
||||
|
||||
implicitWidth: content.implicitWidth
|
||||
implicitHeight: content.implicitHeight
|
||||
|
||||
Column {
|
||||
id: content
|
||||
spacing: root.theme.cardSpacing * 0.5
|
||||
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Workspace " + (root.workspace ? root.workspace.id : "?")
|
||||
color: root.theme.textColor
|
||||
font.pixelSize: 14
|
||||
font.bold: root.workspace && root.workspace.active
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: root.theme.cardSpacing
|
||||
|
||||
Repeater {
|
||||
model: root.toplevels
|
||||
|
||||
WindowCard {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
toplevel: modelData
|
||||
selected: index === root.selectedIndex
|
||||
live: root.live
|
||||
|
||||
onActivated: root.cardClicked(index)
|
||||
}
|
||||
}
|
||||
|
||||
// Placeholder for an empty workspace so the row stays visible
|
||||
// and selectable even with no windows.
|
||||
Rectangle {
|
||||
visible: root.toplevels.length === 0
|
||||
width: root.theme.cardHeight * 1.6
|
||||
height: root.theme.cardHeight
|
||||
radius: root.theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.width: root.selectedIndex === 0 ? 3 : 1
|
||||
border.color: root.selectedIndex === 0 ? root.theme.selectedBorder : root.theme.cardBorder
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Empty"
|
||||
color: root.theme.emptyTextColor
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.cardClicked(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
// Scrolling overview for Hyprland — vertical stack of workspace rows on the
|
||||
// current monitor, each row a horizontal strip of that workspace's windows.
|
||||
// Toggle with `qs -c overview ipc call overview <toggle|open|close>`; wired
|
||||
// to Mod+Tab and a 4-finger swipe in the Hyprland config.
|
||||
ShellRoot {
|
||||
id: shell
|
||||
|
||||
property bool overviewOpen: false
|
||||
|
||||
IpcHandler {
|
||||
target: "overview"
|
||||
|
||||
function toggle(): void {
|
||||
shell.overviewOpen = !shell.overviewOpen;
|
||||
}
|
||||
function open(): void {
|
||||
shell.overviewOpen = true;
|
||||
}
|
||||
function close(): void {
|
||||
shell.overviewOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
|
||||
OverviewWindow {
|
||||
required property var modelData
|
||||
screen: modelData
|
||||
shellOpen: shell.overviewOpen
|
||||
onRequestClose: shell.overviewOpen = false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user