mirror of
https://github.com/flickowoa/dotfiles.git
synced 2026-04-06 00:32:09 +02:00
reimpl battery
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user