Added battey state widget
This commit is contained in:
1 parent
a65fa79bc3
commit
93be64eeaf
4 files changed
+40
-3
No files matched your search
+2
-1
@@ -1,7 +1,7 @@
|
||||
import app from "ags/gtk4/app"
|
||||
import { Astal, Gtk, Gdk } from "ags/gtk4"
|
||||
import Workspaces from "./Workspaces"
|
||||
import { Clock, SysTray } from "./System"
|
||||
import { Clock, SysTray, Battery } from "./System"
|
||||
import Media from "./Media"
|
||||
import Controls from "./Controls"
|
||||
import ThemeSwitcher from "./ThemeSwitcher"
|
||||
@@ -38,6 +38,7 @@ function Right({ gdkmonitor }: { gdkmonitor: Gdk.Monitor }) {
|
||||
>
|
||||
<ThemeSwitcher />
|
||||
<SysTray />
|
||||
<Battery />
|
||||
<Controls gdkmonitor={gdkmonitor} />
|
||||
</box>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Gtk } from "ags/gtk4"
|
||||
import { createPoll } from "ags/time"
|
||||
import AstalTray from "gi://AstalTray?version=0.1"
|
||||
import AstalBattery from "gi://AstalBattery?version=0.1"
|
||||
import { createBinding, For } from "ags"
|
||||
|
||||
export function Clock() {
|
||||
@@ -55,3 +56,22 @@ export function SysTray() {
|
||||
</box>
|
||||
)
|
||||
}
|
||||
|
||||
export function Battery() {
|
||||
const bat = AstalBattery.get_default()
|
||||
return (
|
||||
<box
|
||||
visible={createBinding(bat, "is-present")}
|
||||
cssClasses={["battery"]}
|
||||
valign={Gtk.Align.CENTER}
|
||||
spacing={4}
|
||||
>
|
||||
<image iconName={createBinding(bat, "icon-name")} />
|
||||
<label
|
||||
label={createBinding(bat, "percentage").as(
|
||||
(p) => `${Math.floor(p * 100)}%`,
|
||||
)}
|
||||
/>
|
||||
</box>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user