1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

iSome extra widgets and adjustments

This commit is contained in:
bbedward
2025-07-10 19:11:35 -04:00
parent c4975019e7
commit 052e47614b
13 changed files with 839 additions and 240 deletions

View File

@@ -7,18 +7,19 @@ pragma ComponentBehavior: Bound
Singleton {
id: root
// Battery properties
property bool batteryAvailable: false
property int batteryLevel: 0
property string batteryStatus: "Unknown" // "Charging", "Discharging", "Full", "Not charging", "Unknown"
property int timeRemaining: 0 // minutes
property string batteryStatus: "Unknown"
property int timeRemaining: 0
property bool isCharging: false
property bool isLowBattery: false
property int batteryHealth: 100 // percentage
property int batteryHealth: 100
property string batteryTechnology: "Unknown"
property int cycleCount: 0
property int batteryCapacity: 0 // mAh
property int batteryCapacity: 0
property var powerProfiles: []
property string activePowerProfile: "balanced"
property string activePowerProfile: ""
// Check if battery is available
Process {
@@ -238,12 +239,13 @@ Singleton {
}
}
// Update battery status every 30 seconds
// Update timer
Timer {
interval: 30000
running: root.batteryAvailable
repeat: true
triggeredOnStart: false
triggeredOnStart: true
onTriggered: {
batteryStatusChecker.running = true
powerProfilesChecker.running = true

View File

@@ -145,7 +145,6 @@ Singleton {
running: true
repeat: true
onTriggered: {
console.log(`[MprisController] Players: ${Mpris.players.length}, Active: ${activePlayer?.identity || 'none'}, Playing: ${isPlaying}`)
if (activePlayer) {
console.log(` Track: ${activePlayer.trackTitle || 'Unknown'} by ${activePlayer.trackArtist || 'Unknown'}`)
console.log(` State: ${activePlayer.playbackState}`)

View File

@@ -79,37 +79,49 @@ Singleton {
Process {
id: weatherFetcher
command: ["bash", "-c", "curl -s 'wttr.in/?format=j1' | jq '{current: .current_condition[0], location: .nearest_area[0], astronomy: .weather[0].astronomy[0]}'"]
command: ["bash", "-c", "curl -s 'wttr.in/?format=j1'"]
running: false
stdout: StdioCollector {
onStreamFinished: {
if (text.trim() && text.trim().startsWith("{")) {
try {
let parsedData = JSON.parse(text.trim())
if (parsedData.current && parsedData.location) {
root.weather = {
available: true,
temp: parseInt(parsedData.current.temp_C || 0),
tempF: parseInt(parsedData.current.temp_F || 0),
city: parsedData.location.areaName[0]?.value || "Unknown",
wCode: parsedData.current.weatherCode || "113",
humidity: parseInt(parsedData.current.humidity || 0),
wind: (parsedData.current.windspeedKmph || 0) + " km/h",
sunrise: parsedData.astronomy?.sunrise || "06:00",
sunset: parsedData.astronomy?.sunset || "18:00",
uv: parseInt(parsedData.current.uvIndex || 0),
pressure: parseInt(parsedData.current.pressure || 0)
}
console.log("Weather updated:", root.weather.city, root.weather.temp + "°C")
}
} catch (e) {
console.warn("Failed to parse weather data:", e.message)
root.weather.available = false
}
} else {
const raw = text.trim()
if (!raw || raw[0] !== "{") {
console.warn("No valid weather data received")
root.weather.available = false
return
}
try {
const data = JSON.parse(raw)
const current = data.current_condition?.[0] || {}
const location = data.nearest_area?.[0] || {}
const astronomy = data.weather?.[0]?.astronomy?.[0] || {}
if (!Object.keys(current).length || !Object.keys(location).length) {
throw new Error("Required fields missing")
}
root.weather = {
available: true,
temp: Number(current.temp_C) || 0,
tempF: Number(current.temp_F) || 0,
city: location.areaName?.[0]?.value || "Unknown",
wCode: current.weatherCode || "113",
humidity: Number(current.humidity) || 0,
wind: `${current.windspeedKmph || 0} km/h`,
sunrise: astronomy.sunrise || "06:00",
sunset: astronomy.sunset || "18:00",
uv: Number(current.uvIndex) || 0,
pressure: Number(current.pressure) || 0
}
console.log("Weather updated:", root.weather.city,
`${root.weather.temp}°C`)
} catch (e) {
console.warn("Failed to parse weather data:", e.message)
root.weather.available = false
}
}
}