feat(ags razer): hide percent when charging
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-02-26 01:48:55 -05:00
parent eeea68789c
commit 5287b37f45

View file

@ -53,53 +53,41 @@ const fetchInfo = () => {
interval(RAZER_POLL, fetchInfo); interval(RAZER_POLL, fetchInfo);
// TODO: add charging indicator export default () => {
export default () => Box({ const percentage = Label({ vpack: 'center' });
class_name: 'razer',
children: [
Icon({
hpack: 'start',
icon: RazerBat.bind().transform((v) => {
return v.disconnected ?
'content-loading-symbolic' :
'mouse-razer-symbolic';
}),
setup: (self) => {
self.hook(RazerBat, () => {
const v = RazerBat.value;
self.setCss( const icon = Icon({ hpack: 'start' })
v.disconnected ? .hook(RazerBat, (self) => {
'margin-right: -5px;' : const v = RazerBat.value;
'',
);
self.toggleClassName( percentage.visible = !(v.disconnected || v.charging);
'high', percentage.label = `${v.battery}%`;
v.battery > 66,
);
self.toggleClassName(
'medium',
v.battery > LOW_BATT && v.battery <= 66,
);
self.toggleClassName(
'low',
v.battery <= LOW_BATT,
);
});
},
}),
Label({ self.icon = v.disconnected ?
vpack: 'center', 'content-loading-symbolic' :
label: RazerBat.bind().transform((v) => { 'mouse-razer-symbolic';
if (!v.disconnected) { self.setCss(
// TODO: find better way to indicate charging v.disconnected || v.charging ?
return v.battery + (v.charging ? '󱐋' : '%'); 'margin-right: -5px;' :
} '',
);
return ''; self.toggleClassName(
}), 'high',
}), v.battery > 66,
], );
}); self.toggleClassName(
'medium',
v.battery > LOW_BATT && v.battery <= 66,
);
self.toggleClassName(
'low',
v.battery <= LOW_BATT,
);
});
return Box({
class_name: 'razer',
children: [icon, percentage],
});
};