diff --git a/home/ags/files/Bar.tsx b/home/ags/files/Bar.tsx index e02afdb..19de811 100644 --- a/home/ags/files/Bar.tsx +++ b/home/ags/files/Bar.tsx @@ -1,30 +1,31 @@ -import { Astal, Gdk } from "ags/gtk4"; -import app from "ags/gtk4/app" -import Gtk from "gi://Gtk?version=4.0" -import { createBinding, createState, For, With, Accessor } from "ags" -import { createPoll } from "ags/time" +import { Astal, Gdk, Gtk } from "ags/gtk4"; +import app from "ags/gtk4/app"; +import { createBinding, createState, For, With, Accessor } from "ags"; +import { createPoll } from "ags/time"; import Tray from "gi://AstalTray"; -import { execAsync } from "ags/process" +import { execAsync } from "ags/process"; import Hyprland from "gi://AstalHyprland"; import { getIconName } from "./utils"; -import Wp from "gi://AstalWp" -import Battery from "gi://AstalBattery" +import Wp from "gi://AstalWp"; +import Battery from "gi://AstalBattery"; import GLib from "gi://GLib"; -const battery = Battery.get_default() -const sensorsAvailable = await execAsync(['sensors']).then(() => true).catch(() => false); +const battery = Battery.get_default(); +const sensorsAvailable = await execAsync(["sensors"]) + .then(() => true) + .catch(() => false); const wirePlumber = Wp.get_default(); function SysTray(): JSX.Element { const tray = Tray.get_default(); let items = createBinding(tray, "items"); const init = (btn: Gtk.MenuButton, item: Tray.TrayItem) => { - btn.menuModel = item.menuModel - btn.insert_action_group("dbusmenu", item.actionGroup) + btn.menuModel = item.menuModel; + btn.insert_action_group("dbusmenu", item.actionGroup); item.connect("notify::action-group", () => { - btn.insert_action_group("dbusmenu", item.actionGroup) - }) - } + btn.insert_action_group("dbusmenu", item.actionGroup); + }); + }; return ( @@ -35,7 +36,8 @@ function SysTray(): JSX.Element { $={(self) => init(self, item)} class="systray" tooltipMarkup={createBinding(item, "tooltipMarkup")} - menuModel={createBinding(item, "menuModel")}> + menuModel={createBinding(item, "menuModel")} + > ); @@ -62,74 +64,74 @@ function Center(): JSX.Element { } function Date({ format = "%Y-%m-%d" }): JSX.Element { - const time = createPoll("", 60000, () => GLib.DateTime.new_now_local().format(format)!) - return + return ( + + ); } function Icons() { @@ -170,7 +186,7 @@ function Icons() { - ) + ); } function Volume(): JSX.Element { @@ -178,42 +194,51 @@ function Volume(): JSX.Element { const audio = wirePlumber.audio; const icon = createBinding(audio.default_speaker, "volume").as((volume) => { - const vol = volume * 100 + const vol = volume * 100; const icon = [ - [101, 'overamplified'], - [67, 'high'], - [34, 'medium'], - [1, 'low'], - [0, 'muted'], - ].find(([threshold]) => Number(threshold) <= vol)?.[1] - return `audio-volume-${icon}-symbolic` + [101, "overamplified"], + [67, "high"], + [34, "medium"], + [1, "low"], + [0, "muted"], + ].find(([threshold]) => Number(threshold) <= vol)?.[1]; + return `audio-volume-${icon}-symbolic`; }); const css = createBinding(audio.default_speaker, "mute").as((mute) => { - return mute ? "margin-left:0;" : "margin-left: 0.7em;" + return mute ? "margin-left:0;" : "margin-left: 0.7em;"; }); let volume = createBinding(audio.default_speaker, "volume"); let mute = createBinding(audio.default_speaker, "mute"); return ( - ); } - function Workspaces(): JSX.Element { const hyprland = Hyprland.get_default(); let workspaces = createBinding(hyprland, "workspaces"); @@ -224,14 +249,24 @@ function Workspaces(): JSX.Element { {(fm: Hyprland.Monitor) => { - let filtered_wss = new Accessor(() => wss.sort((a, b) => a.id - b.id) - .filter(ws => ws && ws.get_monitor() && ws.get_monitor().get_id() === fm.get_id())) + let filtered_wss = new Accessor(() => + wss + .sort((a, b) => a.id - b.id) + .filter( + (ws) => + ws && + ws.get_monitor() && + ws.get_monitor().get_id() === fm.get_id(), + ), + ); return ( {(ws: Hyprland.Workspace, _index) => (