add WeatherService, WeatherApplet with hover panel and lock screen widget
This commit is contained in:
parent
6f385130ff
commit
9285365732
8 changed files with 150 additions and 26 deletions
42
shell/services/WeatherService.qml
Normal file
42
shell/services/WeatherService.qml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "." as S
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
property string icon: ""
|
||||
property string tooltip: ""
|
||||
readonly property bool available: icon !== ""
|
||||
|
||||
property Process _proc: Process {
|
||||
running: S.Modules.weather.enable
|
||||
command: ["wttrbar"].concat(S.Modules.weather.args)
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
try {
|
||||
const data = JSON.parse(text);
|
||||
root.icon = data.text ?? "";
|
||||
root.tooltip = data.tooltip ?? "";
|
||||
} catch (e) {
|
||||
root.icon = "";
|
||||
root.tooltip = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Timer _poll: Timer {
|
||||
interval: S.Modules.weather.interval || 3600000
|
||||
running: S.Modules.weather.enable
|
||||
repeat: true
|
||||
onTriggered: root._proc.running = true
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
_proc.running = true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue