From 96757838fc1655ed9ad3118ae915c8cdf091fe35 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 7 Sep 2024 20:05:52 +0000 Subject: add: js bar example --- examples/js/simple-bar/widget/Bar.tsx | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 examples/js/simple-bar/widget/Bar.tsx (limited to 'examples/js/simple-bar/widget') diff --git a/examples/js/simple-bar/widget/Bar.tsx b/examples/js/simple-bar/widget/Bar.tsx new file mode 100644 index 0000000..2b25258 --- /dev/null +++ b/examples/js/simple-bar/widget/Bar.tsx @@ -0,0 +1,130 @@ +import { Variable, Astal, Gtk, Gdk, GLib, bind } from "astal" +import Hyprland from "gi://AstalHyprland" +import Mpris from "gi://AstalMpris" +import Battery from "gi://AstalBattery" +import Wp from "gi://AstalWp" +import Network from "gi://AstalNetwork" + +function Wifi() { + const { wifi } = Network.get_default() + + return +} + +function AudioSlider() { + const speaker = Wp.get_default_wp()?.audio.defaultSpeaker! + + return + + speaker.volume = value} + value={bind(speaker, "volume")} + /> + +} + +function BatteryLevel() { + const bat = Battery.get_default() + + return + + +} + +function Media() { + const player = Mpris.Player.new("spotify") + + return + + `background-image: url('${cover}');` + )} + /> + +} + +function Workspaces() { + const hypr = Hyprland.get_default() + + return + {bind(hypr, "workspaces").as(wss => wss + .sort((a, b) => a.id - b.id) + .map(ws => ( + + )) + )} + +} + +function FocusedClient() { + const hypr = Hyprland.get_default() + const focused = bind(hypr, "focusedClient") + + return + {focused.as(client => ( + client && +} + +function Time({ format = "%H:%M - %A %e." }) { + const time = Variable("").poll(1000, () => + GLib.DateTime.new_now_local().format(format)!) + + return