diff options
Diffstat (limited to 'quickshell/BatteryInfo.qml')
| -rw-r--r-- | quickshell/BatteryInfo.qml | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/quickshell/BatteryInfo.qml b/quickshell/BatteryInfo.qml new file mode 100644 index 0000000..e879d94 --- /dev/null +++ b/quickshell/BatteryInfo.qml @@ -0,0 +1,139 @@ +import QtQuick +import QtQuick.Layouts +import Quickshell +import Quickshell.Io + +Rectangle { + id: batteryInfoRect + + width: 300 + height: 120 + Layout.fillWidth: true + Layout.fillHeight: true + color: shellRoot.black + antialiasing: true + topLeftRadius: 10 + topRightRadius: 10 + property var energy: "" + property var voltage: "" + property var capacity: "" + + Timer { + interval: 0 + running: true + repeat: false + onTriggered: { + fetchProc.running = true; + } + } + + signal requestClose() + focus: true + Keys.onEscapePressed: requestClose() + + Process { + id: fetchProc + command: ["sh", "-c", "~/.config/quickshell/scripts/battery-info.sh"] + + stdout: SplitParser { + onRead: data => { + if (data.includes("energy")) { + energy = data.split(":")[1] + return + } + if (data.includes("voltage")) { + voltage = data.split(":")[1] + return + } + if (data.includes("capacity")) { + capacity = data.split(":")[1] + return + } + } + + } + Component.onCompleted: running = true + } + + RowLayout { + anchors.centerIn: parent + ColumnLayout { + anchors.left: parent + Text { + text: "Energy" + font.family: shellRoot.fontFamily + font.pixelSize: 20 + font.weight: Font.Medium + color: shellRoot.green + MouseArea { + anchors.fill: parent + onClicked: { + } + } + } + Text { + text: "Capacity" + font.family: shellRoot.fontFamily + font.pixelSize: 20 + font.weight: Font.Medium + color: shellRoot.green + MouseArea { + anchors.fill: parent + onClicked: { + } + } + } + Text { + text: "Voltage" + font.family: shellRoot.fontFamily + font.pixelSize: 20 + font.weight: Font.Medium + color: shellRoot.green + MouseArea { + anchors.fill: parent + onClicked: { + } + } + } + } + ColumnLayout { + anchors.right: parent + Text { + text: energy + font.family: shellRoot.fontFamily + font.pixelSize: 20 + font.weight: Font.Medium + color: shellRoot.white + MouseArea { + anchors.fill: parent + onClicked: { + } + } + } + Text { + text: capacity + font.family: shellRoot.fontFamily + font.pixelSize: 20 + font.weight: Font.Medium + color: shellRoot.white + MouseArea { + anchors.fill: parent + onClicked: { + } + } + } + Text { + text: voltage + font.family: shellRoot.fontFamily + font.pixelSize: 20 + font.weight: Font.Medium + color: shellRoot.white + MouseArea { + anchors.fill: parent + onClicked: { + } + } + } + } + } +} |
