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