forked from Shinonome/dots-hyprland
fix low battery notif
This commit is contained in:
@@ -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'
|
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'
|
||||||
// Stuff
|
// Stuff
|
||||||
import userOptions from './modules/.configuration/user_options.js';
|
import userOptions from './modules/.configuration/user_options.js';
|
||||||
|
import { firstRunWelcome } from './services/messages.js';
|
||||||
// Widgets
|
// Widgets
|
||||||
import { Bar, BarCornerTopleft, BarCornerTopright } from './modules/bar/main.js';
|
import { Bar, BarCornerTopleft, BarCornerTopright } from './modules/bar/main.js';
|
||||||
import Cheatsheet from './modules/cheatsheet/main.js';
|
import Cheatsheet from './modules/cheatsheet/main.js';
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ let configOptions = {
|
|||||||
'battery': {
|
'battery': {
|
||||||
'low': 20,
|
'low': 20,
|
||||||
'critical': 10,
|
'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': {
|
'music': {
|
||||||
'preferredPlayer': "plasma-browser-integration",
|
'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;
|
var batteryWarned = false;
|
||||||
async function batteryMessage() {
|
async function batteryMessage() {
|
||||||
const perc = Battery.percent;
|
const perc = Battery.percent;
|
||||||
@@ -39,11 +36,11 @@ async function batteryMessage() {
|
|||||||
batteryWarned = false;
|
batteryWarned = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = BATTERY_WARN_LEVELS.length - 1; i >= 0; i--) {
|
for (let i = userOptions.battery.warnLevels.length - 1; i >= 0; i--) {
|
||||||
if (perc <= BATTERY_WARN_LEVELS[i] && !charging && !batteryWarned) {
|
if (perc <= userOptions.battery.warnLevels[i] && !charging && !batteryWarned) {
|
||||||
batteryWarned = true;
|
batteryWarned = true;
|
||||||
Utils.execAsync(['bash', '-c',
|
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);
|
]).catch(print);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user