diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index aef4724f9..0042a574b 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -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" diff --git a/.config/ags/services/messages.js b/.config/ags/services/messages.js index 44a43e2d0..d94487165 100644 --- a/.config/ags/services/messages.js +++ b/.config/ags/services/messages.js @@ -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