diff --git a/scss/bar.scss b/scss/bar.scss index a0fd2303..ce3e2ea4 100644 --- a/scss/bar.scss +++ b/scss/bar.scss @@ -103,6 +103,14 @@ color: scheme.$mauve; } + .battery { + color: scheme.$teal; + + .low { + color: scheme.$red; + } + } + .date-time { color: scheme.$peach; } diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx index ea953d79..cd36e424 100644 --- a/src/modules/bar.tsx +++ b/src/modules/bar.tsx @@ -11,6 +11,7 @@ import { execAsync, register, Variable } from "astal"; import { bind, kebabify } from "astal/binding"; import { App, Astal, astalify, Gdk, Gtk, type ConstructProps } from "astal/gtk3"; import { bar as config } from "config"; +import AstalBattery from "gi://AstalBattery"; import AstalBluetooth from "gi://AstalBluetooth"; import AstalHyprland from "gi://AstalHyprland"; import AstalNetwork from "gi://AstalNetwork"; @@ -20,6 +21,19 @@ import AstalWp01 from "gi://AstalWp"; const hyprland = AstalHyprland.get_default(); +const getBatteryIcon = (perc: number) => { + if (perc < 0.1) return "󰁺"; + if (perc < 0.2) return "󰁻"; + if (perc < 0.3) return "󰁼"; + if (perc < 0.4) return "󰁽"; + if (perc < 0.5) return "󰁾"; + if (perc < 0.6) return "󰁿"; + if (perc < 0.7) return "󰂀"; + if (perc < 0.8) return "󰂁"; + if (perc < 0.9) return "󰂂"; + return "󰁹"; +}; + const hookFocusedClientProp = ( self: AstalWidget, prop: keyof AstalHyprland.Client, @@ -448,6 +462,13 @@ const NotifCount = () => ( ); +const Battery = () => ( + `module battery ${p < 0.2 ? "low" : ""}`)}> + +); + const DateTime = () => (