feat: ags
This commit is contained in:
15
home-manager/modules/ags/widget/elements/Audio.tsx
Normal file
15
home-manager/modules/ags/widget/elements/Audio.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import { bind } from "astal"
|
||||
import Wp from "gi://AstalWp"
|
||||
|
||||
export default function Audio() {
|
||||
const speaker = Wp.get_default()?.audio.defaultSpeaker!
|
||||
|
||||
return <box className="AudioSlider" css="min-width: 140px">
|
||||
<icon icon={bind(speaker, "volumeIcon")} />
|
||||
<slider
|
||||
hexpand
|
||||
onDragged={({ value }) => speaker.volume = value}
|
||||
value={bind(speaker, "volume")}
|
||||
/>
|
||||
</box>
|
||||
}
|
14
home-manager/modules/ags/widget/elements/Battery.tsx
Normal file
14
home-manager/modules/ags/widget/elements/Battery.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import { bind } from "astal"
|
||||
import Battery from "gi://AstalBattery"
|
||||
|
||||
export default function BatteryLevel() {
|
||||
const bat = Battery.get_default()
|
||||
|
||||
return <box className="Battery"
|
||||
visible={bind(bat, "isPresent")}>
|
||||
<icon icon={bind(bat, "batteryIconName")} />
|
||||
<label label={bind(bat, "percentage").as(p =>
|
||||
`${Math.floor(p * 100)} %`
|
||||
)} />
|
||||
</box>
|
||||
}
|
28
home-manager/modules/ags/widget/elements/Media.tsx
Normal file
28
home-manager/modules/ags/widget/elements/Media.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { bind } from "astal"
|
||||
import { Gtk } from "astal/gtk3"
|
||||
import Mpris from "gi://AstalMpris"
|
||||
|
||||
export default function Media() {
|
||||
const mpris = Mpris.get_default()
|
||||
|
||||
return <box className="Media">
|
||||
{bind(mpris, "players").as(ps => ps[0] ? (
|
||||
<box>
|
||||
<box
|
||||
className="Cover"
|
||||
valign={Gtk.Align.CENTER}
|
||||
css={bind(ps[0], "coverArt").as(cover =>
|
||||
`background-image: url('${cover}');`
|
||||
)}
|
||||
/>
|
||||
<label
|
||||
label={bind(ps[0], "title").as(() =>
|
||||
`${ps[0].title} - ${ps[0].artist}`
|
||||
)}
|
||||
/>
|
||||
</box>
|
||||
) : (
|
||||
"Nothing Playing"
|
||||
))}
|
||||
</box>
|
||||
}
|
18
home-manager/modules/ags/widget/elements/SysTray.tsx
Normal file
18
home-manager/modules/ags/widget/elements/SysTray.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import { bind } from "astal"
|
||||
import Tray from "gi://AstalTray"
|
||||
|
||||
export default function SysTray() {
|
||||
const tray = Tray.get_default()
|
||||
|
||||
return <box className="SysTray">
|
||||
{bind(tray, "items").as(items => items.map(item => (
|
||||
<menubutton
|
||||
tooltipMarkup={bind(item, "tooltipMarkup")}
|
||||
usePopover={false}
|
||||
actionGroup={bind(item, "action-group").as(ag => ["dbusmenu", ag])}
|
||||
menuModel={bind(item, "menu-model")}>
|
||||
<icon gicon={bind(item, "gicon")} />
|
||||
</menubutton>
|
||||
)))}
|
||||
</box>
|
||||
}
|
12
home-manager/modules/ags/widget/elements/Time.tsx
Normal file
12
home-manager/modules/ags/widget/elements/Time.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import { Variable, GLib } from "astal"
|
||||
|
||||
export default function Time({ format = "%H:%M - %A %e." }) {
|
||||
const time = Variable<string>("").poll(1000, () =>
|
||||
GLib.DateTime.new_now_local().format(format)!)
|
||||
|
||||
return <label
|
||||
className="Time"
|
||||
onDestroy={() => time.drop()}
|
||||
label={time()}
|
||||
/>
|
||||
}
|
17
home-manager/modules/ags/widget/elements/Wifi.tsx
Normal file
17
home-manager/modules/ags/widget/elements/Wifi.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
import { bind } from "astal"
|
||||
import Network from "gi://AstalNetwork"
|
||||
|
||||
export default function Wifi() {
|
||||
const network = Network.get_default()
|
||||
const wifi = bind(network, "wifi")
|
||||
|
||||
return <box visible={wifi.as(Boolean)}>
|
||||
{wifi.as(wifi => wifi && (
|
||||
<icon
|
||||
tooltipText={bind(wifi, "ssid").as(String)}
|
||||
className="Wifi"
|
||||
icon={bind(wifi, "iconName")}
|
||||
/>
|
||||
))}
|
||||
</box>
|
||||
}
|
21
home-manager/modules/ags/widget/elements/Workspaces.tsx
Normal file
21
home-manager/modules/ags/widget/elements/Workspaces.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { bind } from "astal"
|
||||
import Hyprland from "gi://AstalHyprland"
|
||||
|
||||
export default function Workspaces() {
|
||||
const hypr = Hyprland.get_default()
|
||||
|
||||
return <box className="Workspaces">
|
||||
{bind(hypr, "workspaces").as(wss => wss
|
||||
.filter(ws => !(ws.id >= -99 && ws.id <= -2)) // filter out special workspaces
|
||||
.sort((a, b) => a.id - b.id)
|
||||
.map(ws => (
|
||||
<button
|
||||
className={bind(hypr, "focusedWorkspace").as(fw =>
|
||||
ws === fw ? "focused" : "")}
|
||||
onClicked={() => ws.focus()}>
|
||||
{ws.id}
|
||||
</button>
|
||||
))
|
||||
)}
|
||||
</box>
|
||||
}
|
Reference in New Issue
Block a user