me like nix
1import QtQuick
2import QtQuick.Layouts
3import Quickshell.Io
4import "../../../config" as Config
5import "../../../components"
6import "../../../services" as Services
7
8Item {
9 id: root
10
11 implicitHeight: weatherLayout.implicitHeight
12
13 property string _condition: ""
14 property string _feelsLike: ""
15 property string _humidity: ""
16 property string _wind: ""
17 property bool _fetched: false
18
19 onVisibleChanged: {
20 if (visible && !_fetched) {
21 weatherDetailProc.running = true
22 _fetched = true
23 }
24 }
25
26 Process {
27 id: weatherDetailProc
28 command: ["sh", "-c", "curl -sf 'wttr.in/?format=%c|%C|%t|%f|%h|%w' | tr -d '+'"]
29 stdout: SplitParser {
30 onRead: data => {
31 if (!data) return
32 var parts = data.trim().split("|")
33 if (parts.length >= 6) {
34 root._condition = parts[1] || ""
35 root._feelsLike = parts[3] || ""
36 root._humidity = parts[4] || ""
37 root._wind = parts[5] || ""
38 }
39 }
40 }
41 }
42
43 ColumnLayout {
44 id: weatherLayout
45 width: parent.width
46 spacing: 16
47
48 // No data
49 ColumnLayout {
50 Layout.fillWidth: true
51 Layout.alignment: Qt.AlignHCenter
52 Layout.topMargin: 32
53 Layout.bottomMargin: 32
54 visible: Services.Weather.weather === ""
55 spacing: 8
56
57 Text {
58 Layout.alignment: Qt.AlignHCenter
59 color: Config.Colours.overlay0
60 font.family: Config.Appearance.font.family
61 font.pixelSize: 32
62 text: "\uf0c2"
63 }
64 Text {
65 Layout.alignment: Qt.AlignHCenter
66 color: Config.Colours.subtext0
67 font.family: Config.Appearance.font.family
68 font.pixelSize: Config.Appearance.font.size.normal
69 text: "Weather data unavailable"
70 }
71 }
72
73 // Current weather
74 ColumnLayout {
75 Layout.fillWidth: true
76 visible: Services.Weather.weather !== ""
77 spacing: 16
78
79 // Large display
80 RowLayout {
81 Layout.fillWidth: true
82 spacing: 16
83
84 Text {
85 color: Config.Colours.yellow
86 font.family: Config.Appearance.font.family
87 font.pixelSize: 48
88 text: "\uf0eb"
89 }
90 ColumnLayout {
91 spacing: 4
92 Text {
93 color: Config.Colours.text
94 font.family: Config.Appearance.font.family
95 font.pixelSize: 28
96 font.bold: true
97 text: Services.Weather.weather
98 }
99 Text {
100 color: Config.Colours.subtext0
101 font.family: Config.Appearance.font.family
102 font.pixelSize: Config.Appearance.font.size.normal
103 text: root._condition || "Loading..."
104 }
105 }
106 }
107
108 Rectangle { Layout.fillWidth: true; height: 1; color: Config.Colours.surface1 }
109
110 // Detail cards
111 RowLayout {
112 Layout.fillWidth: true
113 spacing: 12
114
115 // Feels Like
116 Rectangle {
117 Layout.fillWidth: true
118 implicitHeight: 80
119 radius: Config.Appearance.rounding.normal
120 color: Config.Colours.surface0
121
122 ColumnLayout {
123 anchors.centerIn: parent
124 spacing: 4
125 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.peach; font.family: Config.Appearance.font.family; font.pixelSize: 20; text: "\uf2c9" }
126 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.text; font.family: Config.Appearance.font.family; font.pixelSize: Config.Appearance.font.size.normal; font.bold: true; text: root._feelsLike || "--" }
127 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.overlay0; font.family: Config.Appearance.font.family; font.pixelSize: 10; text: "Feels like" }
128 }
129 }
130
131 // Humidity
132 Rectangle {
133 Layout.fillWidth: true
134 implicitHeight: 80
135 radius: Config.Appearance.rounding.normal
136 color: Config.Colours.surface0
137
138 ColumnLayout {
139 anchors.centerIn: parent
140 spacing: 4
141 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.sapphire; font.family: Config.Appearance.font.family; font.pixelSize: 20; text: "\uf043" }
142 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.text; font.family: Config.Appearance.font.family; font.pixelSize: Config.Appearance.font.size.normal; font.bold: true; text: root._humidity || "--" }
143 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.overlay0; font.family: Config.Appearance.font.family; font.pixelSize: 10; text: "Humidity" }
144 }
145 }
146
147 // Wind
148 Rectangle {
149 Layout.fillWidth: true
150 implicitHeight: 80
151 radius: Config.Appearance.rounding.normal
152 color: Config.Colours.surface0
153
154 ColumnLayout {
155 anchors.centerIn: parent
156 spacing: 4
157 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.teal; font.family: Config.Appearance.font.family; font.pixelSize: 20; text: "\uf72e" }
158 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.text; font.family: Config.Appearance.font.family; font.pixelSize: Config.Appearance.font.size.normal; font.bold: true; text: root._wind || "--" }
159 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.overlay0; font.family: Config.Appearance.font.family; font.pixelSize: 10; text: "Wind" }
160 }
161 }
162 }
163 }
164 }
165}