update introduction to use StdioCollector

This commit is contained in:
outfoxxed 2025-06-09 23:50:32 -07:00
parent 55e272eb2e
commit 1cc0827946
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -66,11 +66,10 @@ To start with lets make a clock. To get the time we'll use the `date` command.
> Quickshell can do more than just run processes. Read until the end for more information. > Quickshell can do more than just run processes. Read until the end for more information.
We can use a [Process](/docs/types/quickshell.io/process) object to run commands We can use a [Process](/docs/types/quickshell.io/process) object to run commands
and return their results. and a @@Quickshell.Io.StdioCollector to read their output.
We'll listen to the @@Quickshell.Io.DataStreamParser.read(s) signal emitted by We'll listen to the @@Quickshell.Io.StdioCollector.streamFinished(s) signal with
@@Quickshell.Io.SplitParser using a a [signal handler](/docs/configuration/qml-overview/#signal-handlers)
[signal handler](/docs/configuration/qml-overview/#signal-handlers)
to update the text on the clock. to update the text on the clock.
> [!note/Note] > [!note/Note]
@ -105,12 +104,13 @@ import QtQuick
// run the command immediately // run the command immediately
running: true running: true
// process the stdout stream using a SplitParser // process the stdout stream using a StdioCollector
// which returns chunks of output after a delimiter // Use StdioCollector to retrieve the text the process sends
stdout: @@Quickshell.Io.SplitParser { // to stdout.
// listen for the read signal, which returns the data that was read stdout: @@Quickshell.Io.StdioCollector {
// from stdout, then write that data to the clock's text property // Listen for the streamFinished signal, which is sent
onRead: data => clock.text = data // when the process closes stdout or exits.
onStreamFinished: clock.text = this.text // `this` can be omitted
} }
} }
} }
@ -148,8 +148,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => clock.text = data onStreamFinished: clock.text = this.text
} }
} }
@ -226,8 +226,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => clock.text = data onStreamFinished: clock.text = this.text
} }
} }
@ -296,8 +296,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => clock.text = data onStreamFinished: clock.text = this.text
} }
} }
@ -380,9 +380,9 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
// update the property instead of the clock directly // update the property instead of the clock directly
onRead: data => root.time = data onStreamFinished: root.time = this.text
} }
} }
@ -445,8 +445,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => root.time = data onStreamFinished: root.time = this.text
} }
} }
@ -512,8 +512,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => root.time = data onStreamFinished: root.time = this.text
} }
} }
@ -591,8 +591,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => root.time = data onStreamFinished: root.time = this.text
} }
} }
@ -625,8 +625,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => root.time = data onStreamFinished: root.time = this.text
} }
} }
@ -701,8 +701,8 @@ import QtQuick
command: ["date"] command: ["date"]
running: true running: true
stdout: @@Quickshell.Io.SplitParser { stdout: @@Quickshell.Io.StdioCollector {
onRead: data => root.time = data onStreamFinished: root.time = this.text
} }
} }