This commit is contained in:
Tigor Hutasuhut 2024-11-21 22:45:00 +07:00
parent e878cd7021
commit 925c62ea95
4 changed files with 60 additions and 33 deletions

11
app.ts
View file

@ -1,10 +1,11 @@
import { App } from "astal/gtk3"
import style from "./style.scss"
import Bar from "./widget/Bar"
import { App } from "astal/gtk3";
import style from "./style.scss";
import Bar from "./widget/Bar";
import Agenda from "./widget/Agenda";
App.start({
css: style,
main() {
App.get_monitors().map(Bar)
App.get_monitors().map(Agenda);
},
})
});

View file

@ -24,7 +24,7 @@
pane name="command"
pane command="bash" {
name "ags"
args "-c" "ags run ./app.ts"
args "-c" "wgo -file=.ts -file=.tsx -xfile=.d.ts -file=.scss ags run ./app.ts"
}
}
}
@ -33,8 +33,10 @@
zellij --layout ${layout} attach --create ags
'';
devStopScript = pkgs.writeShellScriptBin "dev-stop" ''
killall gjs || true
zellij delete-session --force ags || true
'';
agsPkg = ags.packages.${system};
in
{
packages.${system} = {
@ -46,6 +48,7 @@
# additional libraries and executables to add to gjs' runtime
extraPackages = [
agsPkg.hyprland
# ags.packages.${system}.battery
# pkgs.fzf
];
@ -58,12 +61,15 @@
devRunScript
devStopScript
pkgs.zellij
pkgs.typescript
pkgs.wgo
# includes all Astal libraries
# ags.packages.${system}.agsFull
# includes astal3 astal4 astal-io by default
(ags.packages.${system}.default.override {
extraPackages = [
agsPkg.hyprland
# cherry pick packages
];
})

19
widget/Agenda.tsx Normal file
View file

@ -0,0 +1,19 @@
import { App, Astal, Gtk, Gdk } from "astal/gtk3";
import { exec, Variable } from "astal";
const agenda = exec(["gcalcli", "agenda", "--tsv", "--details=end"]);
export default function Agenda(gdkmonitor: Gdk.Monitor) {
agenda.split("\n").map(console.log);
return (
<window
className="Calendar"
gdkmonitor={gdkmonitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={Astal.WindowAnchor.RIGHT}
application={App}
>
<box>{agenda}</box>
</window>
);
}

View file

@ -1,29 +1,30 @@
import { App, Astal, Gtk, Gdk } from "astal/gtk3"
import { Variable } from "astal"
import { App, Astal, Gtk, Gdk } from "astal/gtk3";
import { Variable } from "astal";
const time = Variable("").poll(1000, "date")
const time = Variable("").poll(1000, "date");
export default function Bar(gdkmonitor: Gdk.Monitor) {
return <window
return (
<window
className="Bar"
gdkmonitor={gdkmonitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={Astal.WindowAnchor.TOP
| Astal.WindowAnchor.LEFT
| Astal.WindowAnchor.RIGHT}
application={App}>
anchor={
Astal.WindowAnchor.TOP |
Astal.WindowAnchor.LEFT |
Astal.WindowAnchor.RIGHT
}
application={App}
>
<centerbox>
<button
onClicked="echo hello"
halign={Gtk.Align.CENTER} >
<button onClicked="notify-send hello" halign={Gtk.Align.CENTER}>
Welcome to AGS!
</button>
<box />
<button
onClick={() => print("hello")}
halign={Gtk.Align.CENTER} >
<button onClick={() => print("hello")} halign={Gtk.Align.CENTER}>
<label label={time()} />
</button>
</centerbox>
</window>
);
}