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