fix: show correct icon when battery is 90+
This commit is contained in:
parent
59ae78fb54
commit
58055bf178
2 changed files with 37 additions and 41 deletions
|
@ -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,10 +24,7 @@ export const Bar = Window({
|
|||
style: 'margin: 5px',
|
||||
vertical: false,
|
||||
|
||||
children: [
|
||||
|
||||
// Left
|
||||
Box({
|
||||
startWidget: Box({
|
||||
halign: 'start',
|
||||
children: [
|
||||
|
||||
|
@ -52,14 +49,12 @@ export const Bar = Window({
|
|||
],
|
||||
}),
|
||||
|
||||
// Center
|
||||
CurrentWindow,
|
||||
centerWidget: CurrentWindow,
|
||||
|
||||
// Right
|
||||
Box({
|
||||
endWidget: Box({
|
||||
halign: 'end',
|
||||
children: [
|
||||
BatteryLabel(),
|
||||
Batt,
|
||||
|
||||
Separator(12),
|
||||
|
||||
|
@ -74,6 +69,5 @@ export const Bar = Window({
|
|||
QsToggle,
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue