diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index 5c40dfd8..5579f765 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -1098,11 +1098,16 @@ "dynamic-text": "Dynamischer Text", "display-command-output": { "label": "Befehlsausgabe anzeigen", - "description": "Befehl eingeben, der in regelmäßigen Abständen ausgeführt wird. Die erste Zeile seiner Ausgabe wird als Text angezeigt." + "description": "Befehl eingeben, der in regelmäßigen Abständen ausgeführt wird. Die erste Zeile seiner Ausgabe wird als Text angezeigt.", + "stream-description": "Geben Sie einen Befehl ein, der kontinuierlich ausgeführt werden soll." }, "refresh-interval": { "label": "Aktualisierungsintervall", "description": "Intervall in Millisekunden." + }, + "text-stream": { + "description": "Gestreamte Zeilen aus dem Befehl werden als Text auf der Schaltfläche angezeigt.", + "label": "Strom" } }, "media-mini": { diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index be9571ce..aaae9d49 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -1081,11 +1081,16 @@ "dynamic-text": "Texto dinámico", "display-command-output": { "label": "Mostrar salida de comando", - "description": "Ingresa un comando para ejecutar a intervalos regulares. La primera línea de su salida se mostrará como texto." + "description": "Ingresa un comando para ejecutar a intervalos regulares. La primera línea de su salida se mostrará como texto.", + "stream-description": "Introduce un comando para ejecutar continuamente." }, "refresh-interval": { "label": "Intervalo de actualización", "description": "Intervalo en milisegundos." + }, + "text-stream": { + "description": "Las líneas transmitidas desde el comando se mostrarán como texto en el botón.", + "label": "Transmisión" } }, "media-mini": { diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index 8714859f..f2304dcb 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -1081,11 +1081,16 @@ "dynamic-text": "Texte dynamique", "display-command-output": { "label": "Afficher la sortie de la commande", - "description": "Entrez une commande à exécuter à intervalle régulier. La première ligne de sa sortie sera affichée sous forme de texte." + "description": "Entrez une commande à exécuter à intervalle régulier. La première ligne de sa sortie sera affichée sous forme de texte.", + "stream-description": "Entrez une commande à exécuter en continu." }, "refresh-interval": { "label": "Intervalle d'actualisation", "description": "Intervalle en millisecondes." + }, + "text-stream": { + "description": "Les lignes diffusées depuis la commande seront affichées sous forme de texte sur le bouton.", + "label": "Flux" } }, "media-mini": { diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index 8aab8743..8dfe9ab7 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -1081,11 +1081,16 @@ "dynamic-text": "Texto dinâmico", "display-command-output": { "label": "Exibir Saída de Comando", - "description": "Digite um comando para ser executado em um intervalo regular. A primeira linha da sua saída será exibida como texto." + "description": "Digite um comando para ser executado em um intervalo regular. A primeira linha da sua saída será exibida como texto.", + "stream-description": "Insira um comando para executar continuamente." }, "refresh-interval": { "label": "Intervalo de atualização", "description": "Intervalo em milissegundos." + }, + "text-stream": { + "description": "As linhas transmitidas do comando serão exibidas como texto no botão.", + "label": "Transmissão" } }, "media-mini": { diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index b6464894..a7d6556d 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -1081,11 +1081,16 @@ "dynamic-text": "动态文本", "display-command-output": { "label": "显示命令输出", - "description": "输入一个定期运行的命令。其输出的第一行将显示为文本。" + "description": "输入一个定期运行的命令。其输出的第一行将显示为文本。", + "stream-description": "输入一个要持续运行的命令。" }, "refresh-interval": { "label": "刷新间隔", "description": "间隔时间(毫秒)。" + }, + "text-stream": { + "description": "来自命令的流式输出行将作为文本显示在按钮上。", + "label": "流" } }, "media-mini": { diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index 4e2aceb8..bc05c015 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -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 } diff --git a/Modules/Settings/Bar/WidgetSettings/CustomButtonSettings.qml b/Modules/Settings/Bar/WidgetSettings/CustomButtonSettings.qml index cbd50a5f..1520561e 100644 --- a/Modules/Settings/Bar/WidgetSettings/CustomButtonSettings.qml +++ b/Modules/Settings/Bar/WidgetSettings/CustomButtonSettings.qml @@ -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 }