auto suspend to protect battery

This commit is contained in:
end-4
2024-05-09 20:08:25 +07:00
parent 8e353d1144
commit 066db39268
2 changed files with 7 additions and 0 deletions
@@ -37,6 +37,7 @@ let configOptions = {
'warnLevels': [20, 15, 5],
'warnTitles': ["Low battery", "Very low battery", 'Critical Battery'],
'warnMessages': ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY'],
'suspendThreshold': 3,
},
'brightness': {
// Object of controller names for each monitor, either "brightnessctl" or "ddcutil" or "auto"
+6
View File
@@ -45,6 +45,12 @@ async function batteryMessage() {
break;
}
}
if(perc <= userOptions.battery.suspendThreshold) {
Utils.execAsync(['bash', '-c',
`notify-send "Suspending system" "Critical battery level (${perc}% remaining)" -u critical -a '${APP_NAME}' -t 69420 &`
]).catch(print);
Utils.execAsync('systemctl suspend').catch(print);
}
}
// Run them