From 95710adabe2b4738d9ed74829380feaea142e0a0 Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Sat, 22 Mar 2025 13:32:05 -0400 Subject: [PATCH] Moved AGS project to root, and refactored with flake. --- .envrc | 1 + .gitignore | 2 ++ app.ts | 10 ++++++ env.d.ts | 21 +++++++++++ flake.lock | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 72 ++++++++++++++++++++++++++++++++++++++ scripts/git.fish | 41 ++++++++++++++++++++++ style.scss | 20 +++++++++++ tsconfig.json | 14 ++++++++ widget/Bar.tsx | 25 +++++++++++++ 10 files changed, 297 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 app.ts create mode 100644 env.d.ts create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 scripts/git.fish create mode 100644 style.scss create mode 100644 tsconfig.json create mode 100644 widget/Bar.tsx diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..298eb4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +@girs/ diff --git a/app.ts b/app.ts new file mode 100644 index 0000000..7e8cc7c --- /dev/null +++ b/app.ts @@ -0,0 +1,10 @@ +import { App } from "astal/gtk4" +import style from "./style.scss" +import Bar from "./widget/Bar" + +App.start({ + css: style, + main() { + App.get_monitors().map(Bar) + }, +}) diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 0000000..467c0a4 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,21 @@ +declare const SRC: string + +declare module "inline:*" { + const content: string + export default content +} + +declare module "*.scss" { + const content: string + export default content +} + +declare module "*.blp" { + const content: string + export default content +} + +declare module "*.css" { + const content: string + export default content +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ffbf3f3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,91 @@ +{ + "nodes": { + "ags": { + "inputs": { + "astal": "astal", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738087375, + "narHash": "sha256-GLyNtU9A2VN22jNRHZ2OXuFfTJLh8uEVVt+ftsKUX0c=", + "owner": "aylur", + "repo": "ags", + "rev": "a6a7a0adb17740f4c34a59902701870d46fbb6a4", + "type": "github" + }, + "original": { + "owner": "aylur", + "repo": "ags", + "type": "github" + } + }, + "astal": { + "inputs": { + "nixpkgs": [ + "ags", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737670815, + "narHash": "sha256-ZCxxshGN7XooabArcoGkYSNx5yVunqjKJi2aTv6cznI=", + "owner": "aylur", + "repo": "astal", + "rev": "127e9cdcbf173846a3c40ddc0abfbb038df48042", + "type": "github" + }, + "original": { + "owner": "aylur", + "repo": "astal", + "type": "github" + } + }, + "astal_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1742571008, + "narHash": "sha256-5WgfJAeBpxiKbTR/gJvxrGYfqQRge5aUDcGKmU1YZ1Q=", + "owner": "aylur", + "repo": "astal", + "rev": "dc0e5d37abe9424c53dcbd2506a4886ffee6296e", + "type": "github" + }, + "original": { + "owner": "aylur", + "repo": "astal", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1742422364, + "narHash": "sha256-mNqIplmEohk5jRkqYqG19GA8MbQ/D4gQSK0Mu4LvfRQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a84ebe20c6bc2ecbcfb000a50776219f48d134cc", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "ags": "ags", + "astal": "astal_2", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..36a3f45 --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + + ags = { + url = "github:aylur/ags"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + astal = { + url = "github:aylur/astal"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { self, nixpkgs, ... }@inputs: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + + extraPkgs = with pkgs; [ + fzf + ]; + + agsPkgs = with inputs.ags.packages.${pkgs.system}; [ + apps + bluetooth + greet + hyprland + mpris + network + notifd + tray + wireplumber + ]; + in + { + packages.${system} = { + default = inputs.ags.lib.bundle { + inherit pkgs; + src = ./.; + name = "yash"; # name of executable + entry = "app.ts"; + gtk4 = true; + + # additional libraries and executables to add to gjs' runtime + extraPackages = extraPkgs ++ agsPkgs; + }; + }; + + devShells.${system} = { + default = pkgs.mkShell { + nativeBuildInputs = [ + pkgs.wrapGAppsHook + pkgs.gobject-introspection + (inputs.ags.packages.${system}.agsFull.override { + extraPackages = [ + # include extra libs here to add to the gjs runtime environment + pkgs.libgtop + ]; + }) + ] ++ extraPkgs; + + buildInputs = [ + inputs.astal.packages.${system}.default + pkgs.pnpm + ]; + }; + }; + }; +} diff --git a/scripts/git.fish b/scripts/git.fish new file mode 100644 index 0000000..d7019ee --- /dev/null +++ b/scripts/git.fish @@ -0,0 +1,41 @@ +#!/usr/bin/env fish + +if test (count $argv) -ne 1 + echo "Usage: $argv0 push|pull" + exit 1 +end + +set action $argv[1] +set subtree_path "ags" +set remote "RyotShell-origin" +set branch "main" + +cd (git rev-parse --show-toplevel) +switch $action + case push + set changes (git status --porcelain "$subtree_path") + if test -n "$changes" + set_color yellow; echo " Cannot push. There are uncommitted changes in $subtree_path." + exit 1 + end + git subtree push --prefix="$subtree_path" $remote $branch + case pull + git subtree pull --prefix="$subtree_path" $remote $branch + case commit + set changes (git status --porcelain "$subtree_path") + if test -z "$changes" + echo "No changes to commit in $subtree_path." + exit 0 + end + echo " Enter commit message:" + read commit_message + if test -z "$commit_message" + echo "Commit message cannot be empty." + exit 1 + end + git add "$subtree_path" + git commit -m "$commit_message" + case '*' + echo "Unknown argument. Use push or pull." + exit 1 +end \ No newline at end of file diff --git a/style.scss b/style.scss new file mode 100644 index 0000000..1d0d3a9 --- /dev/null +++ b/style.scss @@ -0,0 +1,20 @@ +// https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/theme/Adwaita/_colors-public.scss +$fg-color: #{"@theme_fg_color"}; +$bg-color: #{"@theme_bg_color"}; + +window.Bar { + background: transparent; + color: $fg-color; + font-weight: bold; + + >centerbox { + background: $bg-color; + border-radius: 10px; + margin: 8px; + } + + button { + border-radius: 8px; + margin: 2px; + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a92bc43 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "experimentalDecorators": true, + "strict": true, + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "Bundler", + // "checkJs": true, + // "allowJs": true, + "jsx": "react-jsx", + "jsxImportSource": "astal/gtk4", + } +} diff --git a/widget/Bar.tsx b/widget/Bar.tsx new file mode 100644 index 0000000..e3a8aca --- /dev/null +++ b/widget/Bar.tsx @@ -0,0 +1,25 @@ +import { App, Astal, Gtk, Gdk } from "astal/gtk4"; +import { Variable } from "astal"; + +const time = Variable("").poll(1000, "date"); + +export default function Bar(gdkmonitor: Gdk.Monitor) { + const { TOP, LEFT, RIGHT } = Astal.WindowAnchor; + + return ( + + + + + + + + + ); +}