Add treefmt

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-02-16 18:53:11 +00:00
parent 22c82653dd
commit 2888bb8b72
70 changed files with 414 additions and 291 deletions

View File

@@ -1,10 +1,10 @@
import { App } from "astal/gtk3"
import Bar from "./widget/Bar"
import { monitorFile } from "astal/file"
import { exec } from "astal/process"
import GLib from "gi://GLib"
import { App } from "astal/gtk3";
import Bar from "./widget/Bar";
import { monitorFile } from "astal/file";
import { exec } from "astal/process";
import GLib from "gi://GLib";
const HOME = GLib.getenv("HOME")
const HOME = GLib.getenv("HOME");
const css = `${HOME}/.config/astal/theme.css`;
const scss = `${HOME}/.config/astal/theme.sass`;
@@ -18,6 +18,6 @@ exec(`sassc ${scss} ${css}`);
App.start({
css,
main() {
App.get_monitors().map(Bar)
App.get_monitors().map(Bar);
},
})
});

View File

@@ -1,26 +1,26 @@
export const SRC: string
export 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 "*.sass" {
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;
}

View File

@@ -7,6 +7,6 @@
"module": "ES2022",
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"jsxImportSource": "astal/gtk3",
"jsxImportSource": "astal/gtk3"
}
}

View File

@@ -1,13 +1,12 @@
import { App, Astal, Gtk, Gdk } from 'astal/gtk3'
import Launcher from './components/Launcher';
import Workspace from './components/Workspaces';
import Date from './components/Date';
import Systray from './components/Tray';
import { App, Astal, Gtk, Gdk } from "astal/gtk3";
import Launcher from "./components/Launcher";
import Workspace from "./components/Workspaces";
import Date from "./components/Date";
import Systray from "./components/Tray";
import Hyprland from "gi://AstalHyprland";
const anchor = Astal.WindowAnchor.TOP
| Astal.WindowAnchor.LEFT
| Astal.WindowAnchor.RIGHT;
const anchor =
Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT;
const hyprland = Hyprland.get_default();
@@ -20,22 +19,25 @@ function getHyprlandMonitor(gdkmonitor: Gdk.Monitor) {
}
}
export default (monitor: Gdk.Monitor) => <window
className='bar'
gdkmonitor={monitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={anchor}
application={App}>
<centerbox className='widgets'>
<box hexpand halign={Gtk.Align.START}>
<Launcher />
<Workspace monitor={getHyprlandMonitor(monitor)!} />
</box>
<box hexpand halign={Gtk.Align.CENTER}>
<Date />
</box>
<box hexpand halign={Gtk.Align.END}>
<Systray />
</box>
</centerbox>
</window>
export default (monitor: Gdk.Monitor) => (
<window
className="bar"
gdkmonitor={monitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={anchor}
application={App}
>
<centerbox className="widgets">
<box hexpand halign={Gtk.Align.START}>
<Launcher />
<Workspace monitor={getHyprlandMonitor(monitor)!} />
</box>
<box hexpand halign={Gtk.Align.CENTER}>
<Date />
</box>
<box hexpand halign={Gtk.Align.END}>
<Systray />
</box>
</centerbox>
</window>
);

View File

@@ -1,13 +1,13 @@
import { Variable } from "astal/variable";
import { GLib } from "astal";
import { Variable } from 'astal/variable';
import { GLib } from 'astal';
const time = Variable<string>("").poll(
1000,
() => GLib.DateTime.new_now_local().format("%H:%M - %A, %d %B %Y")!,
);
const time = Variable<string>("").poll(1000, () => GLib.DateTime.new_now_local().format('%H:%M - %A, %d %B %Y')!)
export default () => <button className='date'>
<label
className='label'
onDestroy={() => time.drop()}
label={time()}
/>
</button>;
export default () => (
<button className="date">
<label className="label" onDestroy={() => time.drop()} label={time()} />
</button>
);

View File

@@ -1,7 +1,12 @@
import { execAsync } from "astal/process"
import { execAsync } from "astal/process";
export default () => <button
className="launcher"
onClickRelease={() => execAsync('bash -c "rofi -cache-dir $XDG_CACHE_HOME/rofi -show drun"')}>
<icon className="icon" icon="nix-snowflake-symbolic" />;
</button>;
export default () => (
<button
className="launcher"
onClickRelease={() =>
execAsync('bash -c "rofi -cache-dir $XDG_CACHE_HOME/rofi -show drun"')
}
>
<icon className="icon" icon="nix-snowflake-symbolic" />;
</button>
);

View File

@@ -1,25 +1,28 @@
import { App } from 'astal/gtk3'
import { bind } from 'astal'
import Tray from 'gi://AstalTray'
import { App } from "astal/gtk3";
import { bind } from "astal";
import Tray from "gi://AstalTray";
const tray = Tray.get_default()
const tray = Tray.get_default();
const TrayButton = ({ item }: { item: Tray.TrayItem }) => (
<menubutton
className='item'
tooltipMarkup={bind(item, 'tooltipMarkup')}
className="item"
tooltipMarkup={bind(item, "tooltipMarkup")}
usePopover={false}
menuModel={bind(item, 'menuModel')}
actionGroup={bind(item, 'actionGroup').as(ag => ['dbusmenu', ag])}
menuModel={bind(item, "menuModel")}
actionGroup={bind(item, "actionGroup").as((ag) => ["dbusmenu", ag])}
>
<icon gicon={bind(item, 'gicon')} />
<icon gicon={bind(item, "gicon")} />
</menubutton>
)
);
export default () => <box className='systray'>
{
bind(tray, 'items').as(items => items.map(item => {
if (item.iconThemePath) App.add_icons(item.iconThemePath);
return <TrayButton item={item} />;
}))}
</box>;
export default () => (
<box className="systray">
{bind(tray, "items").as((items) =>
items.map((item) => {
if (item.iconThemePath) App.add_icons(item.iconThemePath);
return <TrayButton item={item} />;
}),
)}
</box>
);

View File

@@ -1,6 +1,6 @@
import { bind, Variable } from "astal";
import Hyprland from "gi://AstalHyprland";
import { range } from '../../lib';
import { range } from "../../lib";
const hyprland = Hyprland.get_default();
const BLOCK_SIZE = 10;
@@ -20,14 +20,14 @@ const Workspace = ({ id }: { id: number }) => {
const active = Variable.derive(
[bind(hyprland, "focusedWorkspace")],
focused => focused.id == id
(focused) => focused.id == id,
);
hyprland.connect("workspace-added", (_, workspace) => {
if (workspace.id != id) return;
maybeWorkspace.set(workspace);
occupied.set(workspace.clients.length > 0);
workspace.connect("clients", clients => occupied.set(clients.length > 0))
workspace.connect("clients", (clients) => occupied.set(clients.length > 0));
});
hyprland.connect("workspace-removed", (_, workspaceId) => {
@@ -36,37 +36,43 @@ const Workspace = ({ id }: { id: number }) => {
occupied.set(false);
});
const className = Variable.derive(
[active, occupied],
(active, occupied) => {
if (active) return "button active";
if (occupied) return "button occupied";
return "button";
}
);
const className = Variable.derive([active, occupied], (active, occupied) => {
if (active) return "button active";
if (occupied) return "button occupied";
return "button";
});
return <box vertical>
<box vexpand />
<eventbox onClickRelease={() => hyprland.dispatch("workspace", `${id}`)}>
<label className={className()} />
</eventbox>
<box vexpand />
</box>;
return (
<box vertical>
<box vexpand />
<eventbox onClickRelease={() => hyprland.dispatch("workspace", `${id}`)}>
<label className={className()} />
</eventbox>
<box vexpand />
</box>
);
};
export default ({ monitor }: { monitor: Hyprland.Monitor }) => {
const workspaces = hyprland.get_workspaces();
const displayWorkspaces = workspaces.filter(w => w.monitor.id === monitor.id);
const displayWorkspaceBlockStart = Math.floor((displayWorkspaces[0].id - 1) / BLOCK_SIZE) * 10;
const displayWorkspaces = workspaces.filter(
(w) => w.monitor.id === monitor.id,
);
const displayWorkspaceBlockStart =
Math.floor((displayWorkspaces[0].id - 1) / BLOCK_SIZE) * 10;
return <eventbox
className="workspaces"
onScroll={(_, e) => {
hyprland.dispatch("workspace", e.delta_y > 0 ? "m+1" : "m-1");
}}
>
<box>
{range(BLOCK_SIZE).map(i => <Workspace id={displayWorkspaceBlockStart + i} />)}
</box>
</eventbox>;
return (
<eventbox
className="workspaces"
onScroll={(_, e) => {
hyprland.dispatch("workspace", e.delta_y > 0 ? "m+1" : "m-1");
}}
>
<box>
{range(BLOCK_SIZE).map((i) => (
<Workspace id={displayWorkspaceBlockStart + i} />
))}
</box>
</eventbox>
);
};