Better battery widget
This commit is contained in:
parent
1b1a398970
commit
1db94740ed
|
@ -152,14 +152,16 @@ function Right() : JSX.Element {
|
||||||
|
|
||||||
function BatteryIcon(): JSX.Element {
|
function BatteryIcon(): JSX.Element {
|
||||||
if (!battery.online) return <box />;
|
if (!battery.online) return <box />;
|
||||||
const icon_name = bind(battery, "percentage").as((percentage) => {
|
return <box> {
|
||||||
|
bind(battery, "percentage").as((percentage) => {
|
||||||
const thresholds = [...Array(11).keys()].map( i => i * 10);
|
const thresholds = [...Array(11).keys()].map( i => i * 10);
|
||||||
const icon = thresholds.find(threshold => threshold >= percentage * 100)
|
const icon = thresholds.find(threshold => threshold >= percentage * 100)
|
||||||
const charging_name = battery.percentage >= 0.99 ? "charged" : "charging"
|
const charging_name = battery.percentage >= 0.99 ? "charged" : "charging"
|
||||||
return battery.charging? `battery-level-${icon}-${charging_name}-symbolic` : `battery-level-${icon}-symbolic`
|
|
||||||
});
|
|
||||||
return <box className="battery-item" tooltip_text={`Battery ${battery.percentage * 100}%`}>
|
return <box className="battery-item" tooltip_text={`Battery ${battery.percentage * 100}%`}>
|
||||||
<icon icon={icon_name} />
|
<icon icon={battery.charging? `battery-level-${icon}-${charging_name}-symbolic` : `battery-level-${icon}-symbolic`} />
|
||||||
|
</box>
|
||||||
|
})
|
||||||
|
}
|
||||||
</box>
|
</box>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,9 +276,10 @@ function Clients() : JSX.Element {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Bar(gdkmonitor: Gdk.Monitor) {
|
export default function Bar(gdkmonitor: Gdk.Monitor, scaleFactor: number = 1): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<window
|
<window
|
||||||
|
css={"font-size: " + scaleFactor + "em;"}
|
||||||
className="Bar"
|
className="Bar"
|
||||||
gdkmonitor={gdkmonitor}
|
gdkmonitor={gdkmonitor}
|
||||||
exclusivity={Astal.Exclusivity.EXCLUSIVE}
|
exclusivity={Astal.Exclusivity.EXCLUSIVE}
|
||||||
|
|
|
@ -23,7 +23,8 @@ App.start({
|
||||||
main() {
|
main() {
|
||||||
let mainMonitor = find_main_monitor()
|
let mainMonitor = find_main_monitor()
|
||||||
let gtkMonitor = App.get_monitors()[Number(mainMonitor.get_id())]
|
let gtkMonitor = App.get_monitors()[Number(mainMonitor.get_id())]
|
||||||
Bar(gtkMonitor)
|
let scale = (mainMonitor.get_width() >= 3000)? 1.2: 1
|
||||||
|
Bar(gtkMonitor, scale)
|
||||||
NotificationPopups(gtkMonitor)
|
NotificationPopups(gtkMonitor)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue