fix: detect niri availability from event stream; fix workspaces visibility
This commit is contained in:
parent
e3cae59ac3
commit
1b5bdd3010
4 changed files with 7 additions and 8 deletions
|
|
@ -132,7 +132,7 @@ PanelWindow {
|
||||||
leftEdge: true
|
leftEdge: true
|
||||||
M.Workspaces {
|
M.Workspaces {
|
||||||
bar: bar
|
bar: bar
|
||||||
visible: M.Modules.workspaces.enable
|
visible: M.Modules.workspaces.enable && M.NiriIpc.available
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
M.BarGroup {
|
M.BarGroup {
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ QtObject {
|
||||||
signal windowFocusChanged(var windowId)
|
signal windowFocusChanged(var windowId)
|
||||||
signal windowOpenedOrChanged(var window)
|
signal windowOpenedOrChanged(var window)
|
||||||
|
|
||||||
readonly property bool available: Quickshell.env("NIRI_SOCKET") !== ""
|
property bool available: false
|
||||||
|
|
||||||
property string focusedTitle: ""
|
property string focusedTitle: ""
|
||||||
property string focusedAppId: ""
|
property string focusedAppId: ""
|
||||||
property bool overviewOpen: false
|
property bool overviewOpen: false
|
||||||
|
|
||||||
property var _focusedProc: Process {
|
property var _focusedProc: Process {
|
||||||
running: root.available
|
running: true
|
||||||
command: ["niri", "msg", "--json", "focused-window"]
|
command: ["niri", "msg", "--json", "focused-window"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
|
|
@ -37,13 +37,14 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
property var _eventStream: Process {
|
property var _eventStream: Process {
|
||||||
running: root.available
|
running: true
|
||||||
command: ["niri", "msg", "--json", "event-stream"]
|
command: ["niri", "msg", "--json", "event-stream"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: "\n"
|
splitMarker: "\n"
|
||||||
onRead: line => {
|
onRead: line => {
|
||||||
try {
|
try {
|
||||||
const ev = JSON.parse(line);
|
const ev = JSON.parse(line);
|
||||||
|
root.available = true;
|
||||||
if (ev.WorkspacesChanged !== undefined)
|
if (ev.WorkspacesChanged !== undefined)
|
||||||
root.workspacesChanged(ev.WorkspacesChanged.workspaces);
|
root.workspacesChanged(ev.WorkspacesChanged.workspaces);
|
||||||
else if (ev.WorkspaceActivated !== undefined)
|
else if (ev.WorkspaceActivated !== undefined)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import "." as M
|
||||||
M.BarSection {
|
M.BarSection {
|
||||||
id: root
|
id: root
|
||||||
spacing: M.Theme.moduleSpacing
|
spacing: M.Theme.moduleSpacing
|
||||||
visible: M.Modules.windowTitle.enable && M.NiriIpc.available && M.NiriIpc.focusedTitle !== ""
|
visible: M.Modules.windowTitle.enable && M.NiriIpc.focusedTitle !== ""
|
||||||
|
|
||||||
tooltip: M.NiriIpc.focusedAppId ? M.NiriIpc.focusedAppId + "\n" + M.NiriIpc.focusedTitle : M.NiriIpc.focusedTitle
|
tooltip: M.NiriIpc.focusedAppId ? M.NiriIpc.focusedAppId + "\n" + M.NiriIpc.focusedTitle : M.NiriIpc.focusedTitle
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,10 @@ Row {
|
||||||
readonly property string _output: bar.screen?.name ?? ""
|
readonly property string _output: bar.screen?.name ?? ""
|
||||||
readonly property var _workspaces: _allWorkspaces.filter(w => w.output === root._output)
|
readonly property var _workspaces: _allWorkspaces.filter(w => w.output === root._output)
|
||||||
|
|
||||||
visible: M.NiriIpc.available
|
|
||||||
|
|
||||||
// Initial state
|
// Initial state
|
||||||
Process {
|
Process {
|
||||||
id: initProc
|
id: initProc
|
||||||
running: M.NiriIpc.available
|
running: true
|
||||||
command: ["niri", "msg", "--json", "workspaces"]
|
command: ["niri", "msg", "--json", "workspaces"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue