CustomButton stream: i18n + autofmt

This commit is contained in:
ItsLemmy
2025-10-22 10:18:28 -04:00
parent 4da0b353dc
commit 3eef346319
7 changed files with 45 additions and 22 deletions
+14 -14
View File
@@ -99,18 +99,18 @@ Item {
SplitParser {
id: textStdoutSplit
onRead: (line) => _dynamicText = String(line || "").trim()
onRead: line => _dynamicText = String(line || "").trim()
}
StdioCollector {
id: textStdoutCollect
onStreamFinished: () => {
var out = String(this.text || "").trim()
if (out.indexOf("\n") !== -1) {
out = out.split("\n")[0]
}
_dynamicText = out
}
var out = String(this.text || "").trim()
if (out.indexOf("\n") !== -1) {
out = out.split("\n")[0]
}
_dynamicText = out
}
}
Process {
@@ -118,11 +118,11 @@ Item {
stdout: textStream ? textStdoutSplit : textStdoutCollect
stderr: StdioCollector {}
onExited: (exitCode, exitStatus) => {
if (textStream) {
Logger.w("CustomButton", `Streaming text command exited (code: ${exitCode}), restarting...`)
return
}
}
if (textStream) {
Logger.w("CustomButton", `Streaming text command exited (code: ${exitCode}), restarting...`)
return
}
}
}
function onClicked() {
@@ -153,9 +153,9 @@ Item {
function runTextCommand() {
if (!textCommand || textCommand.length === 0)
return
return
if (textProc.running)
return
return
textProc.command = ["sh", "-lc", textCommand]
textProc.running = true
}
@@ -104,9 +104,7 @@ ColumnLayout {
id: textCommandInput
Layout.fillWidth: true
label: I18n.tr("bar.widget-settings.custom-button.display-command-output.label")
description: valueTextStream ?
I18n.tr("bar.widget-settings.custom-button.display-command-output.stream-description") :
I18n.tr("bar.widget-settings.custom-button.display-command-output.description")
description: valueTextStream ? I18n.tr("bar.widget-settings.custom-button.display-command-output.stream-description") : I18n.tr("bar.widget-settings.custom-button.display-command-output.description")
placeholderText: I18n.tr("placeholders.command-example")
text: widgetData?.textCommand || widgetMetadata.textCommand
}