forked from Shinonome/dots-hyprland
auto suspend to protect battery
This commit is contained in:
@@ -37,6 +37,7 @@ let configOptions = {
|
|||||||
'warnLevels': [20, 15, 5],
|
'warnLevels': [20, 15, 5],
|
||||||
'warnTitles': ["Low battery", "Very low battery", 'Critical Battery'],
|
'warnTitles': ["Low battery", "Very low battery", 'Critical Battery'],
|
||||||
'warnMessages': ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY'],
|
'warnMessages': ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY'],
|
||||||
|
'suspendThreshold': 3,
|
||||||
},
|
},
|
||||||
'brightness': {
|
'brightness': {
|
||||||
// Object of controller names for each monitor, either "brightnessctl" or "ddcutil" or "auto"
|
// Object of controller names for each monitor, either "brightnessctl" or "ddcutil" or "auto"
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ async function batteryMessage() {
|
|||||||
break;
|
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
|
// Run them
|
||||||
|
|||||||
Reference in New Issue
Block a user