oh-my-posh icon indicating copy to clipboard operation
oh-my-posh copied to clipboard

Condition evaluation in powerline_symbol

Open blindzero opened this issue 1 week ago • 1 comments

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

What would you like to see changed?

It would be great if the powerline_symbol could evaluate conditions, e.g. as

{
          "background": "#516BEB",
          "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_powerline_symbol": "\ue0b2",
          "powerline_symbol": "{{if eq \"Charging\" .State.String}}<transparent,#40c4ff>\ue0b2</>{{end}}{{if eq \"Discharging\" .State.String}}<transparent,#ff5722>\ue0b2</>{{end}}{{if eq \"Full\" .State.String}}<transparent,#4caf50>\ue0b2</>{{end}}",
          "properties": {
            "charged_icon": "\ue22f ",
            "charging_icon": "\ueb2d ",
            "discharging_icon": "\uf244 "
          },
          "style": "powerline",
          "template": " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}\uf295 ",
          "type": "battery"
        }

The purpose is to have different colors on the symbol to match the template style. Without the conditions the color is not matching 2 of the 3 possible states: image image

blindzero avatar Jun 30 '24 12:06 blindzero