Skip to content

Conversation

@ranger-ross
Copy link

This PR adds a "Hide When No Battery Found" option to Battery section of the Bar configuration.

image

When its enabled the battery module will be hidden if the battery type is not ASTAL_BATTERY_TYPE_BATTERY. (see available types here).

This option is disabled by default.

Disabled Enabled
image image

fixes #940

@Jas-SinghFSU
Copy link
Owner

Couldn't we add

    const isVisible = Variable.derive(
        [bind(batteryService, 'device-type'), bind(hideModuleWhenNoBatteryFound)],
        (deviceType: number, hideModuleWhenNoBatteryFound: boolean) => {
            const isBattery = deviceType === AstalBattery.Type.ASTAL_BATTERY_TYPE_BATTERY;
            return !hideModuleWhenNoBatteryFound || isBattery;
        },
    );

Directly to the isVisible of BatteryLabel (idk why I named it that).

@ranger-ross
Copy link
Author

I originally tried that but there were two problems I ran into:

  1. It seems isVisible does not respect state changes and needs to be a primative boolean.
  2. Even when hardcoding is isVisible to false there is still an empty container that is rendered by the WidgetContainer

I could be incorrect since I've never used this framework but I couldn't get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dont show battery on 0%

2 participants