mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
auto suspend to protect battery
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user