From 7f729d18d9d85f914b6cb1f4df81207caeee4b61 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Thu, 28 Nov 2024 10:03:42 +0100 Subject: init --- .gitignore | 2 + app.ts | 10 ++++ env.d.ts | 21 +++++++ flake.lock | 70 +++++++++++++++++++++++ flake.nix | 61 ++++++++++++++++++++ style.scss | 20 +++++++ tsconfig.json | 22 ++++++++ widget/Bar.tsx | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++ widget/Battery.tsx | 12 ++++ widget/Button.tsx | 34 +++++++++++ 10 files changed, 414 insertions(+) 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 style.scss create mode 100644 tsconfig.json create mode 100644 widget/Bar.tsx create mode 100644 widget/Battery.tsx create mode 100644 widget/Button.tsx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5d317c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +@girs/ +node_modules/ diff --git a/app.ts b/app.ts new file mode 100644 index 0000000..83217ef --- /dev/null +++ b/app.ts @@ -0,0 +1,10 @@ +import { App } from "astal/gtk3" +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..4e7e508 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,21 @@ +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..5e628c1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,70 @@ +{ + "nodes": { + "ags": { + "inputs": { + "astal": "astal", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731966249, + "narHash": "sha256-9hDeMy6S2q1wWBFGiJic5yUms19zW8LhAX9MlCtuN6k=", + "owner": "aylur", + "repo": "ags", + "rev": "12e0bfefd2051c43d7450123fcb095f655b891e8", + "type": "github" + }, + "original": { + "owner": "aylur", + "repo": "ags", + "type": "github" + } + }, + "astal": { + "inputs": { + "nixpkgs": [ + "ags", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731952585, + "narHash": "sha256-Sh1E7sJd8JJM3PCU1ZOei/QWz97OLCENIi2rTRoaniw=", + "owner": "aylur", + "repo": "astal", + "rev": "664c7a4ddfcf48c6e8accd3c33bb94424b0e8609", + "type": "github" + }, + "original": { + "owner": "aylur", + "repo": "astal", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "ags": "ags", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ae0c3c5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,61 @@ +{ + description = "My Awesome Desktop Shell"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + + ags = { + url = "github:aylur/ags"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + ags, + }: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + packages.${system} = { + default = ags.lib.bundle { + inherit pkgs; + src = ./.; + name = "my-shell"; + entry = "app.ts"; + + # additional libraries and executables to add to gjs' runtime + extraPackages = [ + ags.packages.${system}.battery + ags.packages.${system}.hyprland + ags.packages.${system}.mpris + ags.packages.${system}.wireplumber + ags.packages.${system}.network + ags.packages.${system}.tray + ]; + }; + }; + + devShells.${system} = { + default = pkgs.mkShell { + buildInputs = [ + # includes all Astal libraries + # ags.packages.${system}.agsFull + + # includes astal3 astal4 astal-io by default + (ags.packages.${system}.default.override { + extraPackages = [ + ags.packages.${system}.battery + ags.packages.${system}.hyprland + ags.packages.${system}.mpris + ags.packages.${system}.wireplumber + ags.packages.${system}.network + ags.packages.${system}.tray + ]; + }) + ]; + }; + }; + }; +} diff --git a/style.scss b/style.scss new file mode 100644 index 0000000..9ae9604 --- /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 +$theme_fg_color: "@theme_fg_color"; +$theme_bg_color: "@theme_bg_color"; + +window.Bar { + background: transparent; + color: #{$theme_bg_color}; + font-weight: bold; + + >centerbox { + background: #{$theme_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..fc32463 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "$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": "/nix/store/1pd4fdq90f4vla3zghmfci9axsbvkd3w-astal-gjs/share/astal/gjs/gtk3", + "paths": { + "astal": [ + "/nix/store/1pd4fdq90f4vla3zghmfci9axsbvkd3w-astal-gjs/share/astal/gjs" + ], + "astal/*": [ + "/nix/store/1pd4fdq90f4vla3zghmfci9axsbvkd3w-astal-gjs/share/astal/gjs/*" + ] + }, + } +} diff --git a/widget/Bar.tsx b/widget/Bar.tsx new file mode 100644 index 0000000..efc065a --- /dev/null +++ b/widget/Bar.tsx @@ -0,0 +1,162 @@ +import { App } from "astal/gtk3" +import { Variable, GLib, bind } from "astal" +import { Astal, Gtk, Gdk } from "astal/gtk3" +import Hyprland from "gi://AstalHyprland" +import Mpris from "gi://AstalMpris" +import Battery from "gi://AstalBattery" +import Wp from "gi://AstalWp" +import Network from "gi://AstalNetwork" +import Tray from "gi://AstalTray" + +function SysTray() { + const tray = Tray.get_default() + + return + {bind(tray, "items").as(items => items.map(item => { + if (item.iconThemePath) + App.add_icons(item.iconThemePath) + + const menu = item.create_menu() + + return + }))} + +} + +function Wifi() { + const { wifi } = Network.get_default() + + return +} + +function AudioSlider() { + const speaker = Wp.get_default()?.audio.defaultSpeaker! + + return + + speaker.volume = value} + value={bind(speaker, "volume")} + /> + +} + +function BatteryLevel() { + const bat = Battery.get_default() + + return + + +} + +function Media() { + const mpris = Mpris.get_default() + + return + {bind(mpris, "players").as(ps => ps[0] ? ( + + + `background-image: url('${cover}');` + )} + /> + + ) : ( + "Nothing Playing" + ))} + +} + +function Workspaces() { + const hypr = Hyprland.get_default() + + return + {bind(hypr, "workspaces").as(wss => wss + .sort((a, b) => a.id - b.id) + .map(ws => ( + + )) + )} + +} + +function FocusedClient() { + const hypr = Hyprland.get_default() + const focused = bind(hypr, "focusedClient") + + return + {focused.as(client => ( + client && +} + +function Time({ format = "%H:%M - %A %e." }) { + const time = Variable("").poll(1000, () => + GLib.DateTime.new_now_local().format(format)!) + + return