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 { App } from "astal/gtk3";
import style from "./style.scss" import style from "./style.scss";
import Bar from "./widget/Bar" import Bar from "./widget/Bar";
import Agenda from "./widget/Agenda";
App.start({ App.start({
css: style, css: style,
main() { main() {
App.get_monitors().map(Bar) App.get_monitors().map(Agenda);
}, },
}) });

View file

@ -24,7 +24,7 @@
pane name="command" pane name="command"
pane command="bash" { pane command="bash" {
name "ags" 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 zellij --layout ${layout} attach --create ags
''; '';
devStopScript = pkgs.writeShellScriptBin "dev-stop" '' devStopScript = pkgs.writeShellScriptBin "dev-stop" ''
killall gjs || true
zellij delete-session --force ags || true zellij delete-session --force ags || true
''; '';
agsPkg = ags.packages.${system};
in in
{ {
packages.${system} = { packages.${system} = {
@ -46,6 +48,7 @@
# additional libraries and executables to add to gjs' runtime # additional libraries and executables to add to gjs' runtime
extraPackages = [ extraPackages = [
agsPkg.hyprland
# ags.packages.${system}.battery # ags.packages.${system}.battery
# pkgs.fzf # pkgs.fzf
]; ];
@ -58,12 +61,15 @@
devRunScript devRunScript
devStopScript devStopScript
pkgs.zellij pkgs.zellij
pkgs.typescript
pkgs.wgo
# includes all Astal libraries # includes all Astal libraries
# ags.packages.${system}.agsFull # ags.packages.${system}.agsFull
# includes astal3 astal4 astal-io by default # includes astal3 astal4 astal-io by default
(ags.packages.${system}.default.override { (ags.packages.${system}.default.override {
extraPackages = [ extraPackages = [
agsPkg.hyprland
# cherry pick packages # 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 { App, Astal, Gtk, Gdk } from "astal/gtk3";
import { Variable } from "astal" import { Variable } from "astal";
const time = Variable("").poll(1000, "date") const time = Variable("").poll(1000, "date");
export default function Bar(gdkmonitor: Gdk.Monitor) { export default function Bar(gdkmonitor: Gdk.Monitor) {
return <window return (
<window
className="Bar" className="Bar"
gdkmonitor={gdkmonitor} gdkmonitor={gdkmonitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE} exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={Astal.WindowAnchor.TOP anchor={
| Astal.WindowAnchor.LEFT Astal.WindowAnchor.TOP |
| Astal.WindowAnchor.RIGHT} Astal.WindowAnchor.LEFT |
application={App}> Astal.WindowAnchor.RIGHT
}
application={App}
>
<centerbox> <centerbox>
<button <button onClicked="notify-send hello" halign={Gtk.Align.CENTER}>
onClicked="echo hello"
halign={Gtk.Align.CENTER} >
Welcome to AGS! Welcome to AGS!
</button> </button>
<box /> <box />
<button <button onClick={() => print("hello")} halign={Gtk.Align.CENTER}>
onClick={() => print("hello")}
halign={Gtk.Align.CENTER} >
<label label={time()} /> <label label={time()} />
</button> </button>
</centerbox> </centerbox>
</window> </window>
);
} }