PageSourceSearch

https://ohmyposh.dev/assets/js/490709f7.709334e1.js

js ohmyposh.dev collected 2026-09-24 18:50:37 UTC 7,937 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[5609],{2242(e,t,n){n.r(t),n.d(t,{assets:()=>h,contentTitle:()=>l,default:()=>x,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"segments/system/battery","title":"Battery","description":"What","source":"@site/docs/segments/system/battery.mdx","sourceDirName":"segments/system","slug":"/segments/system/battery","permalink":"/docs/segments/system/battery","draft":false,"unlisted":false,"editUrl":"https://github.com/jandedobbeleer/oh-my-posh/edit/main/website/docs/segments/system/battery.mdx","tags":[],"version":"current","frontMatter":{"id":"battery","title":"Battery","sidebar_label":"Battery"},"sidebar":"docs","previous":{"title":"System","permalink":"/docs/category/system"},"next":{"title":"Connection","permalink":"/docs/segments/system/connection"}}');var r=n(4848),i=n(8453),d=n(6674);const c={id:"battery",title:"Battery",sidebar_label:"Battery"},l=void 0,h={},o=[{value:"What",id:"what",level:2},{value:"Sample Configuration",id:"sample-configuration",level:2},{value:"Options",id:"options",level:2},{value:"Template (info)",id:"template-info",level:2},{value:"Properties",id:"properties",level:3}];function a(e){const t={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h2,{id:"what",children:"What"}),"\n",(0,r.jsx)(t.admonition,{type:"caution",children:(0,r.jsx)(t.p,{children:"The segment is not supported and automatically disabled on Windows when WSL 1 is detected. Works fine with WSL 2."})}),"\n",(0,r.jsx)(t.p,{children:"Battery displays the remaining power percentage for your battery."}),"\n",(0,r.jsx)(t.h2,{id:"sample-configuration",children:"Sample Configuration"}),"\n","\n",(0,r.jsx)(d.A,{data:{type:"battery",style:"powerline",powerline_symbol:"\ue0b0",foreground:"#193549",background:"#ffeb3b",background_templates:['{{if eq "Charging" .State.String}}#40c4ff{{end}}','{{if eq "Discharging" .State.String}}#ff5722{{end}}','{{if eq "Full" .State.String}}#4caf50{{end}}'],template:" {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}
1\uf295 ",options:{discharging_icon:"\ue231 ",charging_icon:"\ue234 ",charged_icon:"\ue22f "}}}),"\n",(0,r.jsx)(t.h2,{id:"options",children:"Options"}),"\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{children:"Name"}),(0,r.jsx)(t.th,{style:{textAlign:"center"},children:"Type"}),(0,r.jsx)(t.th,{style:{textAlign:"center"},children:"Default"}),(0,r.jsx)(t.th,{children:"Description"})]})}),(0,r.jsxs)(t.tbody,{children:[(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"display_error"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"},children:(0,r.jsx)(t.code,{children:"boolean"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"},children:(0,r.jsx)(t.code,{children:"false"})}),(0,r.jsx)(t.td,{children:"show the error context when failing to retrieve the battery information"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"charging_icon"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"},children:(0,r.jsx)(t.code,{children:"string"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"}}),(0,r.jsx)(t.td,{children:"icon to display when charging"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"discharging_icon"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"},children:(0,r.jsx)(t.code,{children:"string"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"}}),(0,r.jsx)(t.td,{children:"icon to display when discharging"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"charged_icon"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"},children:(0,r.jsx)(t.code,{children:"string"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"}}),(0,r.jsx)(t.td,{children:"icon to display when fully charged"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"not_charging_icon"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"},children:(0,r.jsx)(t.code,{children:"string"})}),(0,r.jsx)(t.td,{style:{textAlign:"center"}}),(0,r.jsx)(t.td,{children:"icon to display when on AC power"})]})]})]}),"\n",(0,r.jsxs)(t.h2,{id:"template-info",children:["Template (",(0,r.jsx)(t.a,{href:"/docs/configuration/templates",children:"info"}),")"]}),"\n",(0,r.jsx)(t.admonition,{title:"default template",type:"note",children:(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-template",children:" {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}\n"})})}),"\n",(0,r.jsx)(t.h3,{id:"properties",children:"Properties"}),"\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{children:"Name"}),(0,r.jsx)(t.th,{children:"Type"}),(0,r.jsx)(t.th,{children:"Description"})]})}),(0,r.jsxs)(t.tbody,{children:[(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".State"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"struct"})}),(0,r.jsxs)(t.td,{children:["the battery state, has a ",(0,r.jsx)(t.code,{children:".String"})," function"]})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Current"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}),(0,r.jsx)(t.td,{children:"Current (momentary) charge rate (in mW)."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Full"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}
1),(0,r.jsx)(t.td,{children:"Last known full capacity (in mWh)"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Design"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}),(0,r.jsx)(t.td,{children:"Reported design capacity (in mWh)"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".ChargeRate"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}),(0,r.jsxs)(t.td,{children:["Current (momentary) charge rate (in mW). It is always non-negative, consult .State field to check whether it means charging or discharging (on some systems this might be always ",(0,r.jsx)(t.code,{children:"0"})," if the battery doesn't support it)"]})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Voltage"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}),(0,r.jsx)(t.td,{children:"Current voltage (in V)"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".DesignVoltage"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}),(0,r.jsxs)(t.td,{children:["Design voltage (in V). Some systems (e.g. macOS) do not provide a separate value for this. In such cases, or if getting this fails, but getting ",(0,r.jsx)(t.code,{children:"Voltage"})," succeeds, this field will have the same value as ",(0,r.jsx)(t.code,{children:"Voltage"}),", for convenience"]})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Percentage"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"float64"})}),(0,r.jsx)(t.td,{children:"the current battery percentage"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Error"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"string"})}),(0,r.jsx)(t.td,{children:"the error in case fetching the battery information failed"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:".Icon"})}),(0,r.jsx)(t.td,{children:(0,r.jsx)(t.code,{children:"string"})}),(0,r.jsx)(t.td,{children:"the icon based on the battery state"})]})]})]})]})}function x(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.