JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.02k stars 2.37k forks source link

Battery segment no longer displays in Powershell #1736

Closed ngreatorex closed 2 years ago

ngreatorex commented 2 years ago

Code of Conduct

What happened?

I upgraded oh-my-posh to v7.16.0 today and the battery segment has disappeared from my prompt on my laptop. I expected to see the battery segment as I did with the older version (known working on v7.5.1).

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "segments": [
        {
          "background": "#0077c2",
          "foreground": "#ffffff",
          "leading_diamond": "\ue0b6",
          "properties": {
            "mapped_shell_names": {
              "cmd": "Command Prompt",
              "pwsh": "PowerShell"
            },
            "template": " \uf489 {{ .Name }} "
          },
          "style": "diamond",
          "trailing_diamond": "<transparent,background>\ue0b2</>",
          "type": "shell"
        },
        {
          "background": "#4caf50",
          "background_templates": [
            "{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
            "{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
            "{{if eq \"Full\" .State.String}}#4caf50{{end}}"
          ],
          "foreground": "#ffffff",
          "invert_powerline": true,
          "leading_diamond": "\ue0b2",
          "powerline_symbol": "\ue0b2",
          "properties": {
            "charged_icon": "\uf0e7 ",
            "charging_icon": "\uf240 \uf0e7 ",
            "discharging_icon": "\uf240 ",
            "template": " {{ if not .Error }}{{.Icon}}{{.Percentage}}%{{ end }} "
          },
          "style": "diamond",
          "trailing_diamond": "<transparent,background>\ue0b2</>",
          "type": "battery"
        },
        {
          "background": "#2e9599",
          "foreground": "#111111",
          "leading_diamond": "\ue0b2",
          "properties": {
            "template": " {{ .CurrentDate | date .Format }} "
          },
          "style": "diamond",
          "trailing_diamond": "\ue0b4",
          "type": "time"
        }
      ],
      "type": "rprompt"
    }
  ],
  "final_space": true,
  "version": 1
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

Version: 7.16.0

Segments:

ConsoleTitle(false) -   0 ms -
shell(true)    -   0 ms -   PowerShell 
battery(false) -   0 ms -
time(true)     -   0 ms -  16:12:57 

Run duration: 1.0905ms

Cache path: C:\Users\ngreatorex\AppData\Local/oh-my-posh

Logs:

2022/02/09 16:12:57 Args duration: 0s, args:
2022/02/09 16:12:57 Args duration: 0s, args:
2022/02/09 16:12:57 Args duration: 0s, args:
2022/02/09 16:12:57 Shell duration: 0s, args:
2022/02/09 16:12:57 debug: Getenv

2022/02/09 16:12:57 Getenv duration: 44.3µs, args: OMP_CACHE_DISABLED
2022/02/09 16:12:57 debug: Pwd
D:\
2022/02/09 16:12:57 Pwd duration: 0s, args:
2022/02/09 16:12:57 debug: Home
C:\Users\ngreatorex
2022/02/09 16:12:57 PathSeperator duration: 0s, args:
2022/02/09 16:12:57 PathSeperator duration: 0s, args:
2022/02/09 16:12:57 debug: Pwd
D:\
2022/02/09 16:12:57 Pwd duration: 0s, args:
2022/02/09 16:12:57 debug: Home
C:\Users\ngreatorex
2022/02/09 16:12:57 Shell duration: 0s, args:
2022/02/09 16:12:57 Root duration: 0s, args:
2022/02/09 16:12:57 Shell duration: 0s, args:
2022/02/09 16:12:57 ErrorCode duration: 0s, args:
2022/02/09 16:12:57 IsWsl duration: 0s, args:
2022/02/09 16:12:57 debug: Pwd
D:\
2022/02/09 16:12:57 Pwd duration: 0s, args:
2022/02/09 16:12:57 debug: Home
C:\Users\ngreatorex
2022/02/09 16:12:57 PathSeperator duration: 0s, args:
2022/02/09 16:12:57 PathSeperator duration: 0s, args:
2022/02/09 16:12:57 User duration: 0s, args:
2022/02/09 16:12:57 Host duration: 0s, args:
2022/02/09 16:12:57 GOOS duration: 0s, args:
2022/02/09 16:12:57 TemplateCache duration: 0s, args:
2022/02/09 16:12:57 debug: Pwd
D:\
2022/02/09 16:12:57 Pwd duration: 0s, args:
2022/02/09 16:12:57 debug: Home
C:\Users\ngreatorex
2022/02/09 16:12:57 IsWsl2 duration: 0s, args:
2022/02/09 16:12:57 debug: Pwd
D:\
2022/02/09 16:12:57 Pwd duration: 0s, args:
2022/02/09 16:12:57 debug: Home
C:\Users\ngreatorex
2022/02/09 16:12:57 TemplateCache duration: 0s, args:
2022/02/09 16:12:57 debug: Getenv
C:\Users\ngreatorex\AppData\Local
2022/02/09 16:12:57 Getenv duration: 0s, args: LOCALAPPDATA
2022/02/09 16:12:57 CachePath duration: 539.3µs, args:
ngreatorex commented 2 years ago

I had a quick look at the code and it strikes me that this change is going to disable the battery segment on ALL environments that aren't WSL2, which I doubt was the intention :smile:

JanDeDobbeleer commented 2 years ago

@ngreatorex I asked @lnu to double check but in that case I think we messed up. Will fix.

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.