40 lines
969 B
QML
40 lines
969 B
QML
import QtQuick
|
|
import Quickshell.Io
|
|
import "." as M
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: M.Theme.moduleSpacing
|
|
tooltip: root.weatherTooltip
|
|
|
|
property string weatherTooltip: ""
|
|
|
|
Process {
|
|
id: proc
|
|
running: true
|
|
command: ["wttrbar"].concat(M.Modules.weather.args)
|
|
stdout: StdioCollector {
|
|
onStreamFinished: {
|
|
try {
|
|
const data = JSON.parse(text);
|
|
label.icon = data.text ?? "";
|
|
root.weatherTooltip = data.tooltip ?? "";
|
|
} catch (e) {
|
|
label.icon = "";
|
|
root.weatherTooltip = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Timer {
|
|
interval: M.Modules.weather.interval || 3600000
|
|
running: true
|
|
repeat: true
|
|
onTriggered: proc.running = true
|
|
}
|
|
|
|
M.BarIcon {
|
|
id: label
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|