aboutsummaryrefslogtreecommitdiff
path: root/script-output/contents/ui/main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'script-output/contents/ui/main.qml')
-rw-r--r--script-output/contents/ui/main.qml36
1 files changed, 36 insertions, 0 deletions
diff --git a/script-output/contents/ui/main.qml b/script-output/contents/ui/main.qml
new file mode 100644
index 0000000..6a52308
--- /dev/null
+++ b/script-output/contents/ui/main.qml
@@ -0,0 +1,36 @@
+import QtQuick
+import QtQuick.Layouts
+import org.kde.plasma.components as PlasmaComponents
+import org.kde.plasma.plasma5support as Plasma5Support
+import org.kde.plasma.plasmoid
+
+PlasmoidItem {
+ id: root
+
+ readonly property string command: Plasmoid.configuration.command.trim()
+ property string output: ""
+
+ preferredRepresentation: fullRepresentation
+
+ Plasma5Support.DataSource {
+ id: executable
+
+ engine: "executable"
+ connectedSources: root.command ? [root.command] : []
+ interval: 5000
+
+ onNewData: function(source, data) {
+ if (source === root.command && typeof data.stdout === "string")
+ root.output = data.stdout.replace(/\s+$/, "")
+ }
+ }
+
+ fullRepresentation: PlasmaComponents.Label {
+ Layout.minimumWidth: Math.max(1, implicitWidth)
+ Layout.minimumHeight: implicitHeight
+
+ textFormat: Text.PlainText
+ verticalAlignment: Text.AlignVCenter
+ text: root.command ? root.output : i18n("Configure a command")
+ }
+}