Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide battery when none is detected #651

Open
J-Me-2307 opened this issue Dec 28, 2024 · 9 comments
Open

Hide battery when none is detected #651

J-Me-2307 opened this issue Dec 28, 2024 · 9 comments

Comments

@J-Me-2307
Copy link

Is your feature request related to a problem? Please describe.
I use a desktop PC that has no battery. But the battery module just shows that I have 0%.

Describe the solution you'd like
It would be great if, instead of just saying 0%, it would hide the battery icon automatically.

@smathles
Copy link
Contributor

You can easily disable the battery module, it's not hard-baked into the bar.
IMO making an automatic disabling script for when a battery is not detected could be complex and might be bad for a lot of edge cases with devices that are "meant" to have a battery but it's been removed etc etc.

If you want to remove it from your setup (like I do on my pc), you can simply remove it from the json entry in the settings window as shown in the wiki here.

@Noobkrusher3000
Copy link

I read the documentation and checked out your link. I imported the text sample as a config.json into hyprpanel. I don't know how I'd remove the battery module.
Is there updated information or am I more confused than I realize?

@smathles
Copy link
Contributor

smathles commented Jan 3, 2025

Simply delete the "battery" entry in the imported text if it's there. You can do this entirely within the GUI.

If it's not there in the GUI field make sure you hit enter to confirm the selection. If it still doesn't work, kill hyprpanel and run it again with hyprpanel -q;hyprpanel to make sure it's not still in the cache for some reason. It shouldn't show up then.

If it still somehow doesn't work, you can search for battery in your ~/.config/hyprpanel/config.json file and remove it there if somehow it wasn't already removed using the GUI. If it is there, it will look like this:

"bar.layouts": {
    "left": [
        ... something
    ],
    "middle": [
        ... something
    ],
    "right": [
        ... something,
        "battery"
        ... something,
    ],
},

This is a bit drastic though, it should be fine to do it all in the GUI. Still good to manually edit the file if you completely ruin something like set transparency to 100% (then obviously can't see what you're selecting lol).

edit: clarification

@Noobkrusher3000
Copy link

Thanks, I'll try when I have time. 👍

@Noobkrusher3000
Copy link

This is the GUI, no visible option for disabling the module.
snapshot_2025-01-03_08-56-43
This is what my config.json looks like at ~/.config/hyprpanel/config.json
snapshot_2025-01-03_08-59-06
I tried importing the example in the configuration guide but it didn't change anything.

@smathles
Copy link
Contributor

smathles commented Jan 4, 2025

So the option to enable modules in hyprpanel is not in the module sections themselves, but in the top section of the "bar" tab itself. The reason why you can't see it in your config is that it's currently set to default values and won't be explicitly overwritten in your configuration.

If you want to remove it, scroll to the top of the gui entry where it is in your screenshot. You'll see a text field at the very top, and a .json entry in that field. Scroll right using your arrow keys to get to the "battery" entry and delete it along with the associated comma. Then everything should work.

@davfsa
Copy link
Contributor

davfsa commented Jan 4, 2025

Just want to remark, a simple "remove from the bar" works for this case, but I would like to request the feature to be added.

Use case is sharing the same bar config between my pc and my laptop, where the pc just shows "0%" in the component.

It would be a nice QOL, and I know that it's a bit too niche 🙃

@NathanBHay
Copy link

I second having this feature. I don't believe adding it will be too hard as long as we address the edge cases correctly. A basic implementation would follow:

isVisible: batteryService.is_present,

In the event that the bar still needs to be accessible for the brightness slider (I'm not sure if devices with a battery but without brightness exist), you could add an optional condition to check if the brightness is above 0. This could cause problems on the edge case that you launch hyprpanel with 0 brightness. A possible fix for this would require a change to Astal to allow for the max to be called as a field of the brightness service (the battery icon should perhaps also be changed in this case).

I'm new to using Hyprpanel so if I got anything wrong about implementation I apologise in advance.

@Noobkrusher3000
Copy link

If you want to remove it, scroll to the top of the gui entry where it is in your screenshot. You'll see a text field at the very top, and a .json entry in that field. Scroll right using your arrow keys to get to the "battery" entry and delete it along with the associated comma. Then everything should work.

This is what helped. Thanks.

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

No branches or pull requests

5 participants