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
);
}
@@ -304,15 +347,20 @@ export default function Bar(gdkmonitor: Gdk.Monitor, scaleFactor: number = 1) {
gdkmonitor={gdkmonitor}
css={"font-size: " + scaleFactor + "em;"}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
- anchor={Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT}
+ anchor={
+ Astal.WindowAnchor.TOP |
+ Astal.WindowAnchor.LEFT |
+ Astal.WindowAnchor.RIGHT
+ }
application={app}
class="Bar"
- name="top-bar" >
+ name="top-bar"
+ >
-
- )
+
+ );
}
diff --git a/home/ags/files/app.ts b/home/ags/files/app.ts
index 48c37cb..0fe4139 100644
--- a/home/ags/files/app.ts
+++ b/home/ags/files/app.ts
@@ -1,35 +1,40 @@
-import app from "ags/gtk4/app"
-import style from "./style.scss"
-import Bar from "./Bar"
+import app from "ags/gtk4/app";
+import style from "./style.scss";
+import Bar from "./Bar";
import Hyprland from "gi://AstalHyprland";
-import NotificationPopups from "./notifications/NotificationPopups"
+import NotificationPopups from "./notifications/NotificationPopups";
const hyprland = Hyprland.get_default();
function find_main_monitor(): Hyprland.Monitor {
- let monitors = hyprland.get_monitors()
+ let monitors = hyprland.get_monitors();
for (let j = 0; j < monitors.length; j++) {
for (const monitor of ["eDP", "DP", "HDMI-A"]) {
for (let i = 0; i < monitors.length; i++) {
- console.log("Checking monitor:", monitors[i].get_name(), "against", monitor + "-" + j)
+ console.log(
+ "Checking monitor:",
+ monitors[i].get_name(),
+ "against",
+ monitor + "-" + j,
+ );
if (monitors[i].get_name() == monitor + "-" + j) {
- return monitors[i]
+ return monitors[i];
}
}
}
}
- return monitors[0]
+ return monitors[0];
}
function register_windows(monitor: Hyprland.Monitor) {
- let gtkMonitor = app.get_monitors()[0]
- let scale = (monitor.get_width() >= 3000) ? 1.2 : 1
- Bar(gtkMonitor, scale)
- NotificationPopups()
+ let gtkMonitor = app.get_monitors()[0];
+ let scale = monitor.get_width() >= 3000 ? 1.2 : 1;
+ Bar(gtkMonitor, scale);
+ NotificationPopups();
}
function switch_to_best_monitor() {
- let mainMonitor = find_main_monitor()
+ let mainMonitor = find_main_monitor();
for (var wd of app.get_windows()) {
wd.destroy();
}
@@ -37,17 +42,19 @@ function switch_to_best_monitor() {
}
hyprland.connect("monitor-added", (_, _monitor: Hyprland.Monitor) => {
- switch_to_best_monitor()
-})
+ switch_to_best_monitor();
+});
hyprland.connect("monitor-removed", () => {
- switch_to_best_monitor()
-})
+ switch_to_best_monitor();
+});
+
+console.log("Trying to find the best monitor");
app.start({
css: style,
iconTheme: "Papirus",
main() {
- switch_to_best_monitor()
+ switch_to_best_monitor();
},
-})
+});
diff --git a/home/ags/files/env.d.ts b/home/ags/files/env.d.ts
index 792ebfd..467c0a4 100644
--- a/home/ags/files/env.d.ts
+++ b/home/ags/files/env.d.ts
@@ -1,21 +1,21 @@
declare const SRC: string
declare module "inline:*" {
- const content: string
- export default content
+ const content: string
+ export default content
}
declare module "*.scss" {
- const content: string
- export default content
+ const content: string
+ export default content
}
declare module "*.blp" {
- const content: string
- export default content
+ const content: string
+ export default content
}
declare module "*.css" {
- const content: string
- export default content
+ const content: string
+ export default content
}
diff --git a/home/ags/files/notifications/Notification.tsx b/home/ags/files/notifications/Notification.tsx
index d1cc08c..08a90cd 100644
--- a/home/ags/files/notifications/Notification.tsx
+++ b/home/ags/files/notifications/Notification.tsx
@@ -1,34 +1,33 @@
-import Gtk from "gi://Gtk?version=4.0"
-import Gdk from "gi://Gdk?version=4.0"
-import Adw from "gi://Adw"
-import GLib from "gi://GLib"
-import AstalNotifd from "gi://AstalNotifd"
-import Pango from "gi://Pango"
-import { timeout } from "ags/time"
+import { Gtk, Gdk } from "ags/gtk4";
+import Adw from "gi://Adw";
+import GLib from "gi://GLib";
+import AstalNotifd from "gi://AstalNotifd";
+import Pango from "gi://Pango";
+import { timeout } from "ags/time";
function isIcon(icon?: string | null) {
- const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!)
- return icon && iconTheme.has_icon(icon)
+ const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!);
+ return icon && iconTheme.has_icon(icon);
}
function fileExists(path: string) {
- return GLib.file_test(path, GLib.FileTest.EXISTS)
+ return GLib.file_test(path, GLib.FileTest.EXISTS);
}
function time(time: number, format = "%H:%M") {
- return GLib.DateTime.new_from_unix_local(time).format(format)!
+ return GLib.DateTime.new_from_unix_local(time).format(format)!;
}
function urgency(n: AstalNotifd.Notification) {
- const { LOW, NORMAL, CRITICAL } = AstalNotifd.Urgency
+ const { LOW, NORMAL, CRITICAL } = AstalNotifd.Urgency;
switch (n.urgency) {
case LOW:
- return "low"
+ return "low";
case CRITICAL:
- return "critical"
+ return "critical";
case NORMAL:
default:
- return "normal"
+ return "normal";
}
}
@@ -36,12 +35,12 @@ export default function Notification({
notification: n,
onHoverLost,
}: {
- notification: AstalNotifd.Notification
- onHoverLost: () => void
+ notification: AstalNotifd.Notification;
+ onHoverLost: () => void;
}) {
const timer = timeout(3000, () => {
- onHoverLost()
- })
+ onHoverLost();
+ });
return (
- timer.cancel()} onLeave={onHoverLost} />
+ timer.cancel()}
+ onLeave={onHoverLost}
+ />
- )
+ );
}
diff --git a/home/ags/files/notifications/NotificationPopups.tsx b/home/ags/files/notifications/NotificationPopups.tsx
index 2a8aab9..484b17d 100644
--- a/home/ags/files/notifications/NotificationPopups.tsx
+++ b/home/ags/files/notifications/NotificationPopups.tsx
@@ -1,39 +1,39 @@
-import app from "ags/gtk4/app"
-import { Astal, Gtk } from "ags/gtk4"
-import AstalNotifd from "gi://AstalNotifd"
-import Notification from "./Notification"
-import { createBinding, For, createState, onCleanup } from "ags"
+import app from "ags/gtk4/app";
+import { Astal, Gtk } from "ags/gtk4";
+import AstalNotifd from "gi://AstalNotifd";
+import Notification from "./Notification";
+import { createBinding, For, createState, onCleanup } from "ags";
export default function NotificationPopups() {
- const monitors = createBinding(app, "monitors")
+ const monitors = createBinding(app, "monitors");
- const notifd = AstalNotifd.get_default()
+ const notifd = AstalNotifd.get_default();
const [notifications, setNotifications] = createState(
new Array(),
- )
+ );
const notifiedHandler = notifd.connect("notified", (_, id, replaced) => {
- const notification = notifd.get_notification(id)
+ const notification = notifd.get_notification(id);
- if (replaced && notifications.get().some(n => n.id === id)) {
- setNotifications((ns) => ns.map((n) => (n.id === id ? notification : n)))
+ if (replaced && notifications.get().some((n) => n.id === id)) {
+ setNotifications((ns) => ns.map((n) => (n.id === id ? notification : n)));
} else {
- setNotifications((ns) => [notification, ...ns])
+ setNotifications((ns) => [notification, ...ns]);
}
- })
+ });
const resolvedHandler = notifd.connect("resolved", (_, id) => {
- setNotifications((ns) => ns.filter((n) => n.id !== id))
- })
+ setNotifications((ns) => ns.filter((n) => n.id !== id));
+ });
// technically, we don't need to cleanup because in this example this is a root component
// and this cleanup function is only called when the program exits, but exiting will cleanup either way
// but it's here to remind you that you should not forget to cleanup signal connections
onCleanup(() => {
- notifd.disconnect(notifiedHandler)
- notifd.disconnect(resolvedHandler)
- })
+ notifd.disconnect(notifiedHandler);
+ notifd.disconnect(resolvedHandler);
+ });
return (
(win as Gtk.Window).destroy()}>
@@ -61,5 +61,5 @@ export default function NotificationPopups() {
)}
- )
+ );
}
diff --git a/home/ags/files/package.json b/home/ags/files/package.json
index 9805e00..6e5aa9d 100644
--- a/home/ags/files/package.json
+++ b/home/ags/files/package.json
@@ -1,5 +1,5 @@
{
- "dependencies": {
- "ags": "*"
- }
+ "dependencies": {
+ "ags": "*"
+ }
}