ags: make osd work, new window management system, lots of improvements

This commit is contained in:
retrozinndev
2025-02-07 16:02:58 -03:00
parent 0bd0b53589
commit b0bd785ddd
24 changed files with 559 additions and 254 deletions
-3
View File
@@ -9,7 +9,6 @@ import { FocusedClient } from "../widget/bar/FocusedClient";
import { Media } from "../widget/bar/Media";
export const Bar: Widget.Window = new Widget.Window({
className: "bar",
monitor: 0,
namespace: "top-bar",
anchor: Astal.WindowAnchor.TOP,
@@ -18,8 +17,6 @@ export const Bar: Widget.Window = new Widget.Window({
canFocus: false,
visible: true,
widthRequest: Gdk.Screen.get_default()?.get_monitor_geometry(0)?.width,
hexpand: false,
vexpand: false,
child: new Widget.Box({
className: "bar-container",
child: new Widget.CenterBox({
+58
View File
@@ -0,0 +1,58 @@
import { Astal, Gtk, Widget } from "astal/gtk3";
import { GLib } from "astal";
import { getDateTime } from "../scripts/time";
export const CenterWindow: Widget.Window = new Widget.Window({
className: "center-window",
namespace: "center-window",
canFocus: true,
monitor: 0,
layer: Astal.Layer.OVERLAY,
exclusivity: Astal.Exclusivity.NORMAL,
visible: false,
height_request: 600,
anchor: Astal.WindowAnchor.TOP,
child: new Widget.Box({
className: "center-window-container",
children: [
new Widget.Box({
className: "vertical left",
orientation: Gtk.Orientation.VERTICAL,
width_request: 300,
children: [
new Widget.Box({
className: "top time date",
orientation: Gtk.Orientation.VERTICAL,
children: [
new Widget.Label({
className: "time",
label: getDateTime().as((dateTime: GLib.DateTime) =>
dateTime.format("%H:%M"))
} as Widget.LabelProps),
new Widget.Label({
className: "date",
label: getDateTime().as((dateTime: GLib.DateTime) =>
dateTime.format("%A, %B %d %Y"))
} as Widget.LabelProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps),
new Widget.Box({
className: "vertical right",
children: [
new Widget.Box({
className: "calendar-box",
child: new Gtk.Calendar({
show_heading: true,
show_day_names: true,
show_week_numbers: false
} as Gtk.Calendar.ConstructorProps)
} as Widget.BoxProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
} as Widget.WindowProps);
+4 -2
View File
@@ -1,12 +1,14 @@
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
import { Astal, Gtk, Widget } from "astal/gtk3";
import { QuickActions } from "../widget/control-center/QuickActions";
import { Tiles } from "../widget/control-center/Tiles";
import { Sliders } from "../widget/control-center/Sliders";
const widgetsContainer: Widget.Box = new Widget.Box({
className: "control-center-container",
orientation: Gtk.Orientation.VERTICAL,
} as Widget.BoxProps,
QuickActions,
Sliders,
Tiles);
export const ControlCenter: Widget.Window = new Widget.Window({
@@ -15,10 +17,10 @@ export const ControlCenter: Widget.Window = new Widget.Window({
canFocus: true,
exclusivity: Astal.Exclusivity.NORMAL,
anchor: Astal.WindowAnchor.TOP | Astal.WindowAnchor.RIGHT,
layer: Astal.Layer.OVERLAY,
margin_top: 10,
margin_right: 10,
width_request: 450,
height_request: 400,
monitor: 0,
visible: false
} as Widget.WindowProps, widgetsContainer);
+42 -53
View File
@@ -1,58 +1,47 @@
import { Astal, Gtk, Widget } from "astal/gtk3";
import { getNotifd, removeNotification } from "../scripts/notification-handler";
import { notifications as popupNotifications } from "../scripts/notification-handler";
import { getNotifd, notifications, removeNotification } from "../scripts/notification-handler";
import AstalNotifd from "gi://AstalNotifd";
import { bind } from "astal";
export const FloatingNotifications: Widget.Window = FloatingNotificationsWindow();
let gtkNotificationPopups: Array<Widget.Box> = [];
function FloatingNotificationsWindow(): Widget.Window {
const notificationsBox = new Widget.Box({
export const FloatingNotifications: Widget.Window = new Widget.Window({
className: "floating-notifications",
namespace: "floating-notifications",
canFocus: false,
anchor: Astal.WindowAnchor.RIGHT,
monitor: 0,
layer: Astal.Layer.OVERLAY,
visible: false,
exclusivity: Astal.Exclusivity.NORMAL,
child: new Widget.Box({
className: "notifications",
orientation: Gtk.Orientation.VERTICAL,
homogeneous: false
} as Widget.BoxProps);
getNotifd().connect("notified", () => {
for(let i = 0; i < popupNotifications.length; i++) {
const notification: AstalNotifd.Notification = popupNotifications[i];
gtkNotificationPopups[i] = new Widget.Box({
className: "notification",
homogeneous: false,
children: [
new Widget.Box({
className: "top",
orientation: Gtk.Orientation.HORIZONTAL,
hexpand: true,
vexpand: false,
children: [
new Widget.Label({
className: "app-name",
halign: Gtk.Align.START,
label: notification.appName || "Unknown Application"
} as Widget.LabelProps),
new Widget.Button({
className: "close-button",
onClick: () => removeNotification(notification.id)
} as Widget.ButtonProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps);
}
})
return new Widget.Window({
className: "window floating-notifications",
namespace: "floating-notifications",
canFocus: false,
anchor: Astal.WindowAnchor.RIGHT,
monitor: 0,
layer: Astal.Layer.OVERLAY,
visible: false,
exclusivity: Astal.Exclusivity.NORMAL,
child: notificationsBox
} as Widget.WindowProps);
}
homogeneous: false,
children: bind(getNotifd(), "notifications").as(() => {
notifications.length > 0 ? notifications.map((notification: AstalNotifd.Notification) =>
new Widget.Box({
className: "notification",
homogeneous: false,
children: [
new Widget.Box({
className: "top",
orientation: Gtk.Orientation.HORIZONTAL,
hexpand: true,
vexpand: false,
children: [
new Widget.Label({
className: "app-name",
halign: Gtk.Align.START,
label: notification.appName || "Unknown Application"
} as Widget.LabelProps),
new Widget.Button({
className: "close-button",
onClick: () => removeNotification(notification.id)
} as Widget.ButtonProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
) : new Widget.Box({})
})
} as Widget.BoxProps)
} as Widget.WindowProps);
+77 -45
View File
@@ -1,48 +1,80 @@
import { bind } from "astal";
import { bind, Binding, Variable } from "astal";
import { Astal, Gtk, Widget } from "astal/gtk3";
import { Time } from "astal/time";
import AstalWp from "gi://AstalWp";
import { Windows } from "../scripts/windows";
import { Wireplumber } from "../scripts/volume";
import AstalWp from "gi://AstalWp?version=0.1";
export const OSD: Widget.Window = OSDWindow();
function OSDWindow() {
return new Widget.Window({
className: "osd-window",
namespace: "osd",
layer: Astal.Layer.OVERLAY,
anchor: Astal.WindowAnchor.BOTTOM,
canFocus: false,
monitor: 0,
visible: false,
child: new Widget.Box({
className: "osd",
children: [
new Widget.Label({
className: "icon",
label: "󰕾",
css: ".icon { color: white; }"
} as Widget.LabelProps),
new Widget.Box({
className: "volume",
orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER,
children: [
new Widget.Label({
className: "value",
label: bind(AstalWp.get_default()?.defaultSpeaker!, "volume").as((volume: number) => `${Math.round(volume * 100)}%`),
halign: Gtk.Align.CENTER
} as Widget.LabelProps),
new Widget.LevelBar({
className: "levelbar",
width_request: 120,
value: bind(AstalWp.get_default()?.defaultSpeaker!, "volume").as((volume: number) => Math.round(volume * 100)),
maxValue: 100,
halign: Gtk.Align.CENTER
} as Widget.LevelBarProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
} as Widget.WindowProps);
export enum OSDModes {
SINK,
BRIGHTNESS
}
let osdMode: Variable<OSDModes> = new Variable<OSDModes>(OSDModes.SINK);
let osdIcon: Binding<string | undefined> = osdMode().as((mode: OSDModes) => {
switch(mode) {
case OSDModes.SINK: return "󰕾";
case OSDModes.BRIGHTNESS: return "󰃠";
default: return "󱧣";
}
});
export function setOSDMode(newMode: OSDModes): void {
osdMode.set(newMode);
}
export const OSD: Widget.Window = new Widget.Window({
namespace: "osd",
layer: Astal.Layer.OVERLAY,
anchor: Astal.WindowAnchor.BOTTOM,
canFocus: false,
margin_bottom: 80,
monitor: 0,
visible: false,
focusOnClick: false,
child: new Widget.Box({
className: "osd",
children: [
new Widget.Label({
className: "icon",
label: osdIcon
} as Widget.LabelProps),
new Widget.Box({
className: "volume",
orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER,
children: [
new Widget.Label({
className: "device",
label: bind(Wireplumber.getDefault().getDefaultSink(), "name").as((name: string) =>
name || "Speaker"),
halign: Gtk.Align.CENTER
} as Widget.LabelProps),
new Widget.Box({
vexpand: false,
expand: false,
children: [
new Widget.LevelBar({
className: "levelbar",
width_request: 120,
value: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) =>
Math.floor(volume * 100)),
maxValue: bind(Wireplumber.getWireplumber(), "defaultSpeaker").as(() =>
Wireplumber.getDefault().getMaxSinkVolume()),
vexpand: false,
expand: false,
halign: Gtk.Align.CENTER
} as Widget.LevelBarProps),
/*new Widget.Label({
className: "value",
label: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) =>
`${Math.floor(volume * 100)}%`),
vexpand: false,
expand: false,
halign: Gtk.Align.CENTER
} as Widget.LabelProps)*/
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
} as Widget.WindowProps);