[Meson] Prepare

This commit is contained in:
2025-04-25 18:14:42 +02:00
parent 99a7a59cf7
commit 3e5136fdbb
9 changed files with 2866 additions and 95 deletions

View File

@@ -1,4 +1,4 @@
import { bind, readFile, Variable, writeFile } from "astal";
import { bind, readFile, writeFile } from "astal";
import { Gtk } from "astal/gtk4";
import AstalBluetooth from "gi://AstalBluetooth";
import BTDevice from "./Device";
@@ -74,7 +74,7 @@ const openBTPicker = () => {
};
const BluetoothPickerList = () => {
let btEnableState = readFile("./btconf") === "true" ? true : false;
let btEnableState = readFile(`${DATADIR}./btconf`) === "true" ? true : false;
bt.adapter.set_powered(btEnableState);
const updateState = () => {

View File

@@ -3,6 +3,7 @@ import { bind, GObject } from "astal";
import AstalHyprland from "gi://AstalHyprland";
import { Gtk } from "astal/gtk4";
const hypr = AstalHyprland.get_default();
const SYNC = GObject.BindingFlags.SYNC_CREATE;
const SysTray = () => {
@@ -48,8 +49,6 @@ const SysTray = () => {
};
const Workspace = () => {
const hypr = AstalHyprland.get_default();
return (
<box>
{bind(hypr, "workspaces").as(wss =>
@@ -61,9 +60,9 @@ const Workspace = () => {
cssClasses={bind(hypr, "focusedWorkspace").as(fw =>
ws === fw
? [
"focused-workspace-button",
"workspace-button",
]
"focused-workspace-button",
"workspace-button",
]
: ["workspace-button"],
)}
onButtonPressed={() => ws.focus()}
@@ -80,88 +79,13 @@ const Workspace = () => {
* displaying all available clients
*/
const ActiveWindow = () => {
const hypr = AstalHyprland.get_default();
const focused = bind(hypr, "focusedClient");
const WindowPopover = (): Gtk.Popover => {
// Set up boxes + Popover
const clients = new Map<string, Gtk.Button>();
const popover = new Gtk.Popover();
const popoverBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
});
const widgetTitle = new Gtk.Label({
cssClasses: ["title-2"],
label: "Available Windows",
});
popoverBox.append(widgetTitle);
const seaparator = new Gtk.Separator({
marginTop: 5,
marginBottom: 10,
});
popoverBox.append(seaparator);
const addClient = (client: AstalHyprland.Client) => {
const clientBox = new Gtk.Box();
// Workspace description
const descWS = new Gtk.Label({ label: "(WS " });
// Workpsace information
const workspace = new Gtk.Label();
client.workspace.bind_property("name", workspace, "label", SYNC);
const windowClassDesc = new Gtk.Label({ label: ") [" });
const windowClass = new Gtk.Label();
windowClass.label = client.get_initial_class();
const titleDesc = new Gtk.Label({ label: "] " });
titleDesc.set_margin_end(2);
const title = new Gtk.Label();
client.bind_property("title", title, "label", SYNC);
clientBox.append(descWS);
clientBox.append(workspace);
clientBox.append(windowClassDesc);
clientBox.append(windowClass);
clientBox.append(titleDesc);
clientBox.append(title);
const button = new Gtk.Button();
button.connect( 'clicked', () => {
client.workspace.focus();
} );
button.set_child(clientBox);
popoverBox.append(button);
clients.set(client.get_address(), button);
};
// Populate with already added clients
const c = hypr.get_clients();
for (let index = 0; index < c.length; index++) {
addClient(c[index]);
}
hypr.connect("client-added", (_, client) => {
addClient(client);
});
hypr.connect("client-removed", (_, client) => {
const c = clients.get(client);
if (c) {
popoverBox.remove(c);
c.run_dispose();
clients.delete(client);
}
});
const popoverBox = WindowPopoverBox();
popover.set_child(popoverBox);
return popover;
@@ -177,19 +101,37 @@ const ActiveWindow = () => {
<button
onClicked={() => windowPopover.popup()}
cssClasses={["bar-button"]}
>
{focused.as(
client =>
client && (
<label label={bind(client, "title").as(String)} />
),
)}
</button>
child={
focused.as(
client =>
client && (
<label label={bind(client, "title").as(String)} />
),
)
}></button>
{windowPopover}
</box>
</box >
);
};
const WindowPopoverBox = () => {
return <box vertical>
<label label={"Available Windows"} cssClasses={['title-2']}></label>
<Gtk.Separator marginTop={5} marginBottom={5}></Gtk.Separator>
<box vertical>
{bind(hypr, 'clients').as(clients => {
return clients.map(client => {
return <box>
<label label={bind(client, 'workspace').as(w => `(WS ${w})`)}></label>
<label label={bind(client, 'initialClass').as(c => `[${c}]`)}></label>
<label label={bind(client, 'title')}></label>
</box>
})
})}
</box>
</box>
}
export default {
Workspace,
ActiveWindow,