oh-my-posh: Battery segment display as error% in windows

Code of Conduct

  • I agree to follow this project’s Code of Conduct

What happened?

Getting error for the battery segment.

image

with error message - oh-my-posh fatal error rendering battery segment:runtime error: invalid memory address or nil pointer dereference

Version

oh-my-posh v3 Windows 10 Windows Terminal / PowerShell 7.1.4

Theme

Custom.

        {
          "type": "battery",
          "style": "powerline",
          "invert_powerline": true,
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#ffeb3b",
          "properties": {
            "battery_icon": "",
            "charging_icon": "\uE234 ",
            "charging_color": "#40c4ff",
            "charged_icon": "\uE22F ",            
            "charged_color": "#4caf50",
            "discharging_icon": "\uE231 ",
            "discharging_color": "#ff5722",
            "color_background": true,
            // "postfix": "\uF295 ",
            "prefix": "<#4caf50,transparent>\uE0B6</> ",
            "postfix": "\u003c#193549\u003e%\u003c/\u003e\u003c#FFFFFF\u003e \u003c/\u003e",
            "display_charging": true,
            "display_error": true,
            "template": "{{.Battery.Status}}"
          }

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Relevant log output

oh-my-posh fatal error rendering battery segment:runtime error: invalid memory address or nil pointer dereference

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Confirm closure of issue - can see now battery% reflecting correctly.

image

Perfect. We can fix that. Seems like there’s at least one battery that works 😅

@pyxelr the help is great but I feel this is a bug in the code nonetheless. Something is off as we try to access data that doesn’t exist. I’ll have a look over the weekend.

on the same computer - it works properly on wsl

image