mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
add MultiTurnProcess
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
Process {
|
||||
id: proc
|
||||
|
||||
signal finished(string output)
|
||||
|
||||
property list<var> sequence: []
|
||||
property int index: 0
|
||||
|
||||
// Runs a sequence of command and functions
|
||||
function runSequence(seq) {
|
||||
if (seq.length == 0)
|
||||
return;
|
||||
sequence = seq;
|
||||
running = false;
|
||||
index = -1;
|
||||
step();
|
||||
}
|
||||
|
||||
function step(output) {
|
||||
index++;
|
||||
if (index >= sequence.length) {
|
||||
finished(output);
|
||||
return;
|
||||
}
|
||||
const nextItem = sequence[index];
|
||||
if (typeof nextItem === "function") {
|
||||
const nextOutput = nextItem(output);
|
||||
step(nextOutput);
|
||||
} else {
|
||||
// If empty command then not set; this allows setting it with previous function
|
||||
if (nextItem.length > 0)
|
||||
command = nextItem;
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
proc.step(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user