reimpl battery

This commit is contained in:
flick0
2023-10-20 07:49:14 +00:00
parent 05c6917b2e
commit ec5d04e8da

View File

@@ -21,10 +21,33 @@ console.log("homedir:: "+ home)
console.log("themedir:: " + themedir)
const battery = Variable(false,{})
const battery = Variable(false,{
poll:[1500,['cat','/sys/class/power_supply/ADP0/online'], out => {
if (out=="1") {
return false
} else if (out=="0") {
return true
}
}]
})
globalThis.battery = battery;
let prev_battery = false
battery.connect('changed', ({ value }) => {
if (prev_battery == value){
return
}
prev_battery = value
if (battery.value) {
App.resetCss();
App.applyCss(App.configDir +`/style-battery.css`);
} else {
App.resetCss();
App.applyCss(App.configDir +`/style.css`);
}
});
function get_color(){
return Utils.readFileAsync(home + '/.config/hypr/themes/uicolors')
.then(content => {
@@ -49,15 +72,6 @@ function get_color(){
//return colors;
}
battery.connect('changed', ({ value }) => {
App.resetCss();
if (battery.value) {
App.applyCss(App.configDir +`/style-battery.css`);
} else {
App.applyCss(App.configDir +`/style.css`);
}
});
Utils.subprocess([
'inotifywait',
'--recursive',