From 58055bf1787f84face150a0b99b44dbda72de37e Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
Date: Fri, 8 Sep 2023 14:14:10 -0400
Subject: [PATCH] fix: show correct icon when battery is 90+

---
 config/ags/js/bar/bar.js     | 68 ++++++++++++++++--------------------
 config/ags/js/bar/battery.js | 10 +++---
 2 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/config/ags/js/bar/bar.js b/config/ags/js/bar/bar.js
index 358972aa..ca258afe 100644
--- a/config/ags/js/bar/bar.js
+++ b/config/ags/js/bar/bar.js
@@ -10,10 +10,10 @@ import { QsToggle }       from './quick-settings.js';
 import { NotifButton }    from './notif-button.js';
 import { Clock }          from './clock.js';
 import { SysTray }        from './systray.js';
-import { BatteryLabel }   from './battery.js';
+import { Batt }           from './battery.js';
 
 export const Bar = Window({
-  name: 'left-bar',
+  name: 'bar',
   layer: 'overlay',
   anchor: 'top left right',
   exclusive: true,
@@ -24,56 +24,50 @@ export const Bar = Window({
     style: 'margin: 5px',
     vertical: false,
     
-    children: [
+    startWidget: Box({
+      halign: 'start',
+      children: [
 
-      // Left
-      Box({
-        halign: 'start',
-        children: [
-
-          OskToggle,
+        OskToggle,
   
-          Separator(12),
+        Separator(12),
 
-          TabletToggle,
+        TabletToggle,
       
-          Separator(12),
+        Separator(12),
 
-          Heart,
+        Heart,
 
-          Separator(12),
+        Separator(12),
 
-          SysTray,
+        SysTray,
 
-          Separator(12),
+        Separator(12),
 
-          Workspaces,
+        Workspaces,
 
-        ],
-      }),
+      ],
+    }),
 
-      // Center
-      CurrentWindow,
+    centerWidget: CurrentWindow,
 
-      // Right
-      Box({
-        halign: 'end',
-        children: [
-          BatteryLabel(),
+    endWidget: Box({
+      halign: 'end',
+      children: [
+        Batt,
+        
+        Separator(12),
+      
+        Clock,
 
-          Separator(12),
+        Separator(12),
 
-          Clock,
+        NotifButton,
 
-          Separator(12),
+        Separator(12),
 
-          NotifButton,
-
-          Separator(12),
-
-          QsToggle,
-        ],
-      }),
-    ],
+        QsToggle,
+      ],
+    }),
   }),
 });
diff --git a/config/ags/js/bar/battery.js b/config/ags/js/bar/battery.js
index de4727b2..79555016 100644
--- a/config/ags/js/bar/battery.js
+++ b/config/ags/js/bar/battery.js
@@ -3,7 +3,7 @@ import { Separator } from '../common.js';
 const { exec } = ags.Utils;
 
 const icons = charging => ([
-  ...Array.from({ length: 9 }, (_, i) => i * 10).map(i => ([
+  ...Array.from({ length: 10 }, (_, i) => i * 10).map(i => ([
     `${i}`, Icon({
       className: `${i} ${charging ? 'charging' : 'discharging'}`,
       icon: `battery-level-${i}${charging ? '-charging' : ''}-symbolic`,
@@ -22,7 +22,7 @@ const Indicators = charging => Stack({
   }]],
 });
 
-export const Indicator = ({
+const Indicator = ({
   charging = Indicators(true),
   discharging = Indicators(false),
   ...props
@@ -43,13 +43,13 @@ export const Indicator = ({
   }]],
 });
 
-export const LevelLabel = props => Label({
+const LevelLabel = props => Label({
   ...props,
   className: 'label',
   connections: [[1000, label => label.label = `${exec('cat /sys/class/power_supply/BAT0/capacity')}%`]],
 });
 
-export const BatteryLabel = () => Box({
+const BatteryLabel = () => Box({
   className: 'toggle-off battery',
   children: [
     Indicator(),
@@ -57,3 +57,5 @@ export const BatteryLabel = () => Box({
     LevelLabel(),
   ],
 });
+
+export const Batt = BatteryLabel();