JanDeDobbeleer / oh-my-posh

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

Battery segment not getting displayed irrespective of battery state #1238

Closed Pranay-Chopra closed 2 years ago

Pranay-Chopra commented 2 years ago

Code of Conduct

What happened?

While using Jandedobbeleer theme, or any theme for that matter, the battery segment doesn't get displayed irrespective of the battery state. No errror messages as well. The segment just doesn't exist.

Expected was to see the battery state (charging, full charge or discharging). Steps to reproduce: Use Powershell 7. Use oh-my-posh 3. Use windows terminal. Load jandedobbeleer theme, or make a custom theme with battery segment enabled. { "type": "battery", "style": "powerline", "invert_powerline": true, "powerline_symbol": "\uE0B2", "foreground": "#ffffff", "background": "#f36943", "properties": { "battery_icon": "", "discharging_icon": " ", "charging_icon": " ", "charged_icon": " ", "color_background": true, "charged_color": "#4caf50", "charging_color": "#40c4ff", "discharging_color": "#ff5722", "postfix": " " } },

Version

I think I am using the latest version, version 3.

Theme

This issue arises on any and every config.

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Relevant log output

No response

JanDeDobbeleer commented 2 years ago

@Pranay-Chopra can you provide the output of (Get-Module oh-my-posh).Version or oh-my-posh --version (depends on how you installed). Additionally: Write-PoshDebug and the contents of ~/oh-my-posh.log.

Pranay-Chopra commented 2 years ago

ok image_2021-11-18_093706

~/oh-my-posh.log

2021/11/18 09:35:40 debug: getenv
C:\Users\HP\AppData\Local
2021/11/18 09:35:40 getenv duration: 512.7µs, args: LOCALAPPDATA
2021/11/18 09:35:40 getCachePath duration: 592.8µs, args: 
2021/11/18 09:35:40 getArgs duration: 0s, args: 
2021/11/18 09:35:40 getArgs duration: 0s, args: 
2021/11/18 09:35:40 getShellName duration: 18.7701ms, args: 
2021/11/18 09:35:40 isRunningAsRoot duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 getPathSeperator duration: 0s, args: 
2021/11/18 09:35:40 getPathSeperator duration: 0s, args: 
2021/11/18 09:35:40 getShellName duration: 0s, args: 
2021/11/18 09:35:40 getCurrentUser duration: 0s, args: 
2021/11/18 09:35:40 getHostName duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 getArgs duration: 0s, args: 
2021/11/18 09:35:40 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:35:40 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:35:40 getPathSeperator duration: 0s, args: 
2021/11/18 09:35:40 getPathSeperator duration: 0s, args: 
2021/11/18 09:35:40 getPathSeperator duration: 0s, args: 
2021/11/18 09:35:40 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:35:40 error: hasCommand
exec: "git.exe": executable file not found in %PATH%
2021/11/18 09:35:40 hasCommand duration: 20.8966ms, args: git.exe
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 isRunningAsRoot duration: 0s, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 error: getBatteryInfo
[{ChargeRate:Unknown value received}]
2021/11/18 09:35:40 getBatteryInfo duration: 6.3991ms, args: 
2021/11/18 09:35:40 getcwd duration: 0s, args: 
2021/11/18 09:35:40 lastErrorCode duration: 0s, args: 
2021/11/18 09:35:40 #### end oh-my-posh run ####
2021/11/18 09:36:07 #### start oh-my-posh run ####
2021/11/18 09:36:07 debug: getenv
C:\Users\HP\AppData\Local
2021/11/18 09:36:07 getenv duration: 0s, args: LOCALAPPDATA
2021/11/18 09:36:07 getCachePath duration: 112.6µs, args: 
2021/11/18 09:36:07 getArgs duration: 0s, args: 
2021/11/18 09:36:07 getArgs duration: 0s, args: 
2021/11/18 09:36:07 getShellName duration: 18.7402ms, args: 
2021/11/18 09:36:07 isRunningAsRoot duration: 0s, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:07 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:07 getShellName duration: 0s, args: 
2021/11/18 09:36:07 getCurrentUser duration: 507.1µs, args: 
2021/11/18 09:36:07 getHostName duration: 83.2µs, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 getArgs duration: 0s, args: 
2021/11/18 09:36:07 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:07 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:07 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:07 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:07 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:07 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:07 error: hasCommand
exec: "git.exe": executable file not found in %PATH%
2021/11/18 09:36:07 hasCommand duration: 17.9078ms, args: git.exe
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 isRunningAsRoot duration: 0s, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 error: getBatteryInfo
[{ChargeRate:Unknown value received}]
2021/11/18 09:36:07 getBatteryInfo duration: 6.0125ms, args: 
2021/11/18 09:36:07 getcwd duration: 0s, args: 
2021/11/18 09:36:07 lastErrorCode duration: 0s, args: 
2021/11/18 09:36:07 #### end oh-my-posh run ####
2021/11/18 09:36:57 #### start oh-my-posh run ####
2021/11/18 09:36:57 debug: getenv
C:\Users\HP\AppData\Local
2021/11/18 09:36:57 getenv duration: 0s, args: LOCALAPPDATA
2021/11/18 09:36:57 getCachePath duration: 0s, args: 
2021/11/18 09:36:57 getArgs duration: 0s, args: 
2021/11/18 09:36:57 getArgs duration: 0s, args: 
2021/11/18 09:36:57 getShellName duration: 16.5637ms, args: 
2021/11/18 09:36:57 isRunningAsRoot duration: 141.8µs, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:57 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:57 getShellName duration: 0s, args: 
2021/11/18 09:36:57 getCurrentUser duration: 0s, args: 
2021/11/18 09:36:57 getHostName duration: 0s, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 getArgs duration: 0s, args: 
2021/11/18 09:36:57 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:57 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:57 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:57 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:57 getPathSeperator duration: 0s, args: 
2021/11/18 09:36:57 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 getRuntimeGOOS duration: 0s, args: 
2021/11/18 09:36:57 error: hasCommand
exec: "git.exe": executable file not found in %PATH%
2021/11/18 09:36:57 hasCommand duration: 17.8722ms, args: git.exe
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 isRunningAsRoot duration: 0s, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 error: getBatteryInfo
[{ChargeRate:Unknown value received}]
2021/11/18 09:36:57 getBatteryInfo duration: 5.1066ms, args: 
2021/11/18 09:36:57 getcwd duration: 0s, args: 
2021/11/18 09:36:57 lastErrorCode duration: 0s, args: 
2021/11/18 09:36:57 #### end oh-my-posh run ####
Pranay-Chopra commented 2 years ago
{
    "final_space": true,
    "blocks": [
        {
            "type": "prompt",
            "alignment": "left",
            "horizontal_offset": 0,
            "vertical_offset": 0,
            "segments": [
                {
                   "type": "text",
                   "style": "diamond",
                   "leading_diamond": "",
                   "trailing_diamond": "",
                   "powerline_symbol": "",
                   "foreground": "#ff0000",
                   "background": "#ffffff",
                   "properties": {
                       "prefix": " ",
                       "text": "PraDevHunter"
                    }
                },  
                {            
                    "type": "path",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#ffffff",
                    "background": "#ff479c",
                    "leading_diamond": "",
                    "trailing_diamond": " ",
                    "properties": {
                        "prefix": "  ",
                        "style": "folder"
                    }
                },
                {
                    "type": "git",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#193549",
                    "background": "#fffb38",
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "display_status": true,
                        "display_stash_count": true,
                        "display_upstream_icon": true
                    }
                },
                {
                    "type": "dotnet",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#ffffff",
                    "background": "#6CA35E",
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "display_version": true,
                        "prefix": "  "
                    }
                },
                {
                    "type": "root",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#ffffff",
                    "background": "#333333",
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": null
                },
                {
                    "type": "battery",
                    "style": "powerline",
                    "invert_powerline": true,
                    "powerline_symbol": "\uE0B2",
                    "foreground": "#ffffff",
                    "background": "#f36943",
                    "properties": {
                      "battery_icon": "",
                      "discharging_icon": " ",
                      "charging_icon": " ",
                      "charged_icon": " ",
                      "color_background": true,
                      "charged_color": "#4caf50",
                      "charging_color": "#40c4ff",
                      "discharging_color": "#ff5722",
                      "postfix": " "
                    }
                },
                {
                    "type": "exit",
                    "style": "diamond",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#ffffff",
                    "background": "#2e9599",
                    "leading_diamond": "",
                    "trailing_diamond": "\ue0c0",
                    "properties": {
                        "always_enabled": true,
                        "color_background": true,
                        "display_exit_code": false,
                        "error_color": "#f1184c",
                        "prefix": " "
                    }
                },
                {
                    "type": "text",
                    "style": "plain",
                    "foreground": "#E06C75",
                    "properties": {
                      "prefix": "",
                      "text": " "
                    }
                  }
            ]
        }
    ]
}
Pranay-Chopra commented 2 years ago

Im on Windows 11 btw

Pranay-Chopra commented 2 years ago

and i used an exe to see my battery info. turns out it uses the same library as oh-my-posh. here is its output: image

JanDeDobbeleer commented 2 years ago

@Pranay-Chopra the rate is indeed off, let me see if this is reproducible on 11 or a device specific issue. If not, I'll adjust the lib to display what it receives and we'll take it from there.

Pranay-Chopra commented 2 years ago

sure... anything I have to do to fix it?

JanDeDobbeleer commented 2 years ago

@Pranay-Chopra no, this is some level stuff that acts differently so the only way to really know is to either have you debug the library or me trying to add more logging to the library to figure out the actual data it receives and fix it.

Pranay-Chopra commented 2 years ago

uhh ok

Pranay-Chopra commented 2 years ago

and you said something is off about the rate. so is that library stuff too or is smth wrong with my battery?

JanDeDobbeleer commented 2 years ago

@Pranay-Chopra the library has a bug on your machine. It's not oh-my-posh. But we can have a look at fixing it.

Pranay-Chopra commented 2 years ago

okay... thanks

Khaos66 commented 2 years ago

@Pranay-Chopra Can you please install the latest version (v6.29.2)? It should be fixed now ;)

Pranay-Chopra commented 2 years ago

is it there on winget?

Pranay-Chopra commented 2 years ago

thanks its fixed now

github-actions[bot] commented 6 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.