@@ -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>
|
||||
);
|
||||
|
@@ -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>
|
||||
);
|
||||
|
@@ -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>
|
||||
);
|
||||
|
@@ -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>
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user