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