forked from Shinonome/dots-hyprland
Added a small battery popup to show information
This commit is contained in:
@@ -4,6 +4,8 @@ import qs
|
||||
import qs.modules.common
|
||||
import Quickshell
|
||||
import Quickshell.Services.UPower
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
Singleton {
|
||||
property bool available: UPower.displayDevice.isLaptopBattery
|
||||
@@ -21,6 +23,43 @@ Singleton {
|
||||
property bool isCriticalAndNotCharging: isCritical && !isCharging
|
||||
property bool isSuspendingAndNotCharging: allowAutomaticSuspend && isSuspending && !isCharging
|
||||
|
||||
property real energyRate: UPower.displayDevice.changeRate
|
||||
property real timeToEmpty: UPower.displayDevice.timeToEmpty
|
||||
property real timeToFull: UPower.displayDevice.timeToFull
|
||||
property real temperature: 0
|
||||
|
||||
Process {
|
||||
id: tempProcess
|
||||
command: ["bash", "-c", "cat /sys/class/thermal/thermal_zone0/temp"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text && text.trim() !== "") {
|
||||
Battery.temperature = parseInt(text.trim()) / 1000
|
||||
} else {
|
||||
Battery.temperature = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 3000
|
||||
repeat: true
|
||||
running: true
|
||||
onTriggered: {
|
||||
if (!tempProcess.running) {
|
||||
tempProcess.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!tempProcess.running) {
|
||||
tempProcess.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onIsLowAndNotChargingChanged: {
|
||||
if (available && isLowAndNotCharging) Quickshell.execDetached([
|
||||
"notify-send",
|
||||
|
||||
Reference in New Issue
Block a user