Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/noko/fixtures/production-probe.qml

Raw
import QtQuick
import Quickshell
import Quickshell.Io
import "../../../features/noko" as NokoFeature

// The production Noko service against the scripted engine installed in the
// sandbox's data directory: dictations driven through its public trigger, text
// typed through the private wtype on PATH, copy through the nested clipboard.
Scope {
    id: root

    NokoFeature.Noko {
        id: service
    }
    Process {
        id: reader
        property string output: ""
        stdout: StdioCollector {
            waitForEnd: true
            onStreamFinished: reader.output = this.text
        }
    }
    IpcHandler {
        target: "uiTest"
        function trigger(): string {
            return service.trigger();
        }
        function state(): string {
            return service.stateJson();
        }
        // Counts only, never text: how far the running dictation has come.
        function progress(): string {
            return JSON.stringify({
                phase: service.overlayState,
                finals: service.finals.length,
                partial: service.partialText.length > 0
            });
        }
        function copy(): void {
            service.copyTranscript("-copy π\nsecond line\n");
        }
        function read(): void {
            reader.exec(["wl-paste", "--no-newline"]);
        }
        function copied(): string {
            return JSON.stringify({
                matches: reader.output === "-copy π\nsecond line\n"
            });
        }
        function insertError(): string {
            return service.lastInsertError;
        }
    }
}