diff options
Diffstat (limited to 'script-output')
| -rw-r--r-- | script-output/README.md | 1 | ||||
| -rw-r--r-- | script-output/contents/config/config.qml | 9 | ||||
| -rw-r--r-- | script-output/contents/config/main.xml | 8 | ||||
| -rw-r--r-- | script-output/contents/ui/configGeneral.qml | 14 | ||||
| -rw-r--r-- | script-output/contents/ui/main.qml | 36 | ||||
| -rw-r--r-- | script-output/metadata.json | 17 |
6 files changed, 85 insertions, 0 deletions
diff --git a/script-output/README.md b/script-output/README.md new file mode 100644 index 0000000..37fdb29 --- /dev/null +++ b/script-output/README.md @@ -0,0 +1 @@ +This is a plasmoid to display the output of a shell command, configurable by right-clicking the plasmoid. diff --git a/script-output/contents/config/config.qml b/script-output/contents/config/config.qml new file mode 100644 index 0000000..de54d9b --- /dev/null +++ b/script-output/contents/config/config.qml @@ -0,0 +1,9 @@ +import org.kde.plasma.configuration + +ConfigModel { + ConfigCategory { + name: i18n("General") + icon: "configure" + source: "configGeneral.qml" + } +} diff --git a/script-output/contents/config/main.xml b/script-output/contents/config/main.xml new file mode 100644 index 0000000..1a5a465 --- /dev/null +++ b/script-output/contents/config/main.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"> + <group name="General"> + <entry name="command" type="String"> + <default></default> + </entry> + </group> +</kcfg> diff --git a/script-output/contents/ui/configGeneral.qml b/script-output/contents/ui/configGeneral.qml new file mode 100644 index 0000000..1ea583d --- /dev/null +++ b/script-output/contents/ui/configGeneral.qml @@ -0,0 +1,14 @@ +import QtQuick.Controls as Controls +import org.kde.kcmutils as KCM +import org.kde.kirigami as Kirigami + +KCM.SimpleKCM { + property alias cfg_command: commandField.text + + Kirigami.FormLayout { + Controls.TextField { + id: commandField + Kirigami.FormData.label: i18n("Command") + } + } +} 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") + } +} diff --git a/script-output/metadata.json b/script-output/metadata.json new file mode 100644 index 0000000..904c54a --- /dev/null +++ b/script-output/metadata.json @@ -0,0 +1,17 @@ +{ + "KPlugin": { + "Id": "local.scriptoutput", + "Name": "Script Output", + "Description": "Displays the output of a shell command", + "Icon": "utilities-terminal", + "Authors": [ + { + "Email": "joel.kronqvist@iki.fi", + "Name": "Joel Kronqvist" + } + ], + "License": "GPL-3.0-or-later" + }, + "KPackageStructure": "Plasma/Applet", + "X-Plasma-API-Minimum-Version": "6.0" +} |
