workspace indicator
This commit is contained in:
parent
be370777f0
commit
9b87c70477
4 changed files with 93 additions and 4 deletions
|
|
@ -50,6 +50,7 @@ PanelWindow {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: M.Theme.barSpacing
|
spacing: M.Theme.barSpacing
|
||||||
|
|
||||||
|
M.Workspaces { visible: M.Modules.workspaces }
|
||||||
M.Tray {
|
M.Tray {
|
||||||
bar: bar
|
bar: bar
|
||||||
visible: M.Modules.tray
|
visible: M.Modules.tray
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import Quickshell.Io
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property bool workspaces: true
|
||||||
property bool tray: true
|
property bool tray: true
|
||||||
property bool windowTitle: true
|
property bool windowTitle: true
|
||||||
property bool clock: true
|
property bool clock: true
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,93 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import Quickshell.Io
|
||||||
|
import "." as M
|
||||||
|
|
||||||
// Placeholder — Quickshell.Services.Niri not yet available
|
Row {
|
||||||
RowLayout {
|
id: root
|
||||||
spacing: M.Theme.moduleSpacing
|
spacing: 4
|
||||||
|
|
||||||
|
property var _workspaces: []
|
||||||
|
property int _activeId: -1
|
||||||
|
|
||||||
|
// Initial state
|
||||||
|
Process {
|
||||||
|
id: initProc
|
||||||
|
running: true
|
||||||
|
command: ["niri", "msg", "--json", "workspaces"]
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
try {
|
||||||
|
const ws = JSON.parse(text);
|
||||||
|
root._workspaces = ws.sort((a, b) => a.idx - b.idx);
|
||||||
|
for (const w of ws) {
|
||||||
|
if (w.is_focused)
|
||||||
|
root._activeId = w.id;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Live updates
|
||||||
|
Process {
|
||||||
|
id: eventStream
|
||||||
|
running: true
|
||||||
|
command: ["niri", "msg", "--json", "event-stream"]
|
||||||
|
stdout: SplitParser {
|
||||||
|
splitMarker: "\n"
|
||||||
|
onRead: line => {
|
||||||
|
try {
|
||||||
|
const ev = JSON.parse(line);
|
||||||
|
if (ev.WorkspacesChanged !== undefined) {
|
||||||
|
root._workspaces = ev.WorkspacesChanged.workspaces
|
||||||
|
.sort((a, b) => a.idx - b.idx);
|
||||||
|
} else if (ev.WorkspaceActivated !== undefined) {
|
||||||
|
if (ev.WorkspaceActivated.focused)
|
||||||
|
root._activeId = ev.WorkspaceActivated.id;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: switchProc
|
||||||
|
property int wsId: -1
|
||||||
|
command: ["niri", "msg", "action", "focus-workspace", String(wsId)]
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root._workspaces
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
id: pill
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
|
||||||
|
readonly property bool active: modelData.id === root._activeId
|
||||||
|
|
||||||
|
width: 20
|
||||||
|
height: 20
|
||||||
|
radius: M.Theme.radius
|
||||||
|
color: pill.active ? M.Theme.base0D : M.Theme.base02
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: pill.modelData.idx
|
||||||
|
color: pill.active ? M.Theme.base00 : M.Theme.base04
|
||||||
|
font.pixelSize: M.Theme.fontSize - 2
|
||||||
|
font.family: M.Theme.fontFamily
|
||||||
|
font.bold: pill.active
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
switchProc.wsId = pill.modelData.id;
|
||||||
|
switchProc.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ in
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
options = lib.genAttrs
|
options = lib.genAttrs
|
||||||
[
|
[
|
||||||
|
"workspaces"
|
||||||
"tray"
|
"tray"
|
||||||
"windowTitle"
|
"windowTitle"
|
||||||
"clock"
|
"clock"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue