mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 20:31:57 +00:00
fix low battery notif
This commit is contained in:
parent
6ef0fec4a0
commit
38fd7195ef
3 changed files with 7 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ import App from 'resource:///com/github/Aylur/ags/app.js'
|
|||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'
|
||||
// Stuff
|
||||
import userOptions from './modules/.configuration/user_options.js';
|
||||
import { firstRunWelcome } from './services/messages.js';
|
||||
// Widgets
|
||||
import { Bar, BarCornerTopleft, BarCornerTopright } from './modules/bar/main.js';
|
||||
import Cheatsheet from './modules/cheatsheet/main.js';
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ let configOptions = {
|
|||
'battery': {
|
||||
'low': 20,
|
||||
'critical': 10,
|
||||
'warnLevels': [20, 15, 5],
|
||||
'warnTitles': ["Low battery", "Very low battery", 'Critical Battery'],
|
||||
'warnMessages': ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY'],
|
||||
},
|
||||
'music': {
|
||||
'preferredPlayer': "plasma-browser-integration",
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@ export async function firstRunWelcome() {
|
|||
}
|
||||
}
|
||||
|
||||
const BATTERY_WARN_LEVELS = [20, 15, 5];
|
||||
const BATTERY_WARN_TITLES = ["Low battery", "Very low battery", 'Critical Battery']
|
||||
const BATTERY_WARN_BODIES = ["Plug in the charger", "You there?", 'PLUG THE CHARGER ALREADY']
|
||||
var batteryWarned = false;
|
||||
async function batteryMessage() {
|
||||
const perc = Battery.percent;
|
||||
|
|
@ -39,11 +36,11 @@ async function batteryMessage() {
|
|||
batteryWarned = false;
|
||||
return;
|
||||
}
|
||||
for (let i = BATTERY_WARN_LEVELS.length - 1; i >= 0; i--) {
|
||||
if (perc <= BATTERY_WARN_LEVELS[i] && !charging && !batteryWarned) {
|
||||
for (let i = userOptions.battery.warnLevels.length - 1; i >= 0; i--) {
|
||||
if (perc <= userOptions.battery.warnLevels[i] && !charging && !batteryWarned) {
|
||||
batteryWarned = true;
|
||||
Utils.execAsync(['bash', '-c',
|
||||
`notify-send "${BATTERY_WARN_TITLES[i]}" "${BATTERY_WARN_BODIES[i]}" -u critical -a 'ags' &`
|
||||
`notify-send "${userOptions.battery.warnTitles[i]}" "${userOptions.battery.warnMessages[i]}" -u critical -a '${APP_NAME}' &`
|
||||
]).catch(print);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue