forked from Shinonome/dots-hyprland
battery: add auto suspend
This commit is contained in:
@@ -12,6 +12,7 @@ Singleton {
|
||||
property bool isCharging: chargeState == UPowerDeviceState.Charging
|
||||
property bool isPluggedIn: isCharging || chargeState == UPowerDeviceState.PendingCharge
|
||||
property real percentage: UPower.displayDevice.percentage
|
||||
readonly property bool allowAutomaticSuspend: ConfigOptions.battery.automaticSuspend
|
||||
|
||||
property bool isLow: percentage <= ConfigOptions.battery.low / 100
|
||||
property bool isCritical: percentage <= ConfigOptions.battery.critical / 100
|
||||
@@ -19,6 +20,7 @@ Singleton {
|
||||
|
||||
property bool isLowAndNotCharging: isLow && !isCharging
|
||||
property bool isCriticalAndNotCharging: isCritical && !isCharging
|
||||
property bool isSuspendingAndNotCharging: allowAutomaticSuspend && isSuspending && !isCharging
|
||||
|
||||
onIsLowAndNotChargingChanged: {
|
||||
if (available && isLowAndNotCharging)
|
||||
@@ -29,4 +31,10 @@ Singleton {
|
||||
if (available && isCriticalAndNotCharging)
|
||||
Quickshell.execDetached(["bash", "-c", `notify-send "Critically low battery" "🙏 I beg for pleas charg\nAutomatic suspend triggers at ${ConfigOptions.battery.suspend}%" -u critical -a "Shell"`]);
|
||||
}
|
||||
|
||||
onIsSuspendingAndNotChargingChanged: {
|
||||
if (available && isSuspendingAndNotCharging) {
|
||||
Quickshell.execDetached(["bash", "-c", `systemctl suspend || loginctl suspend`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user