ags: init rewrite

This commit is contained in:
notohh 2024-04-18 00:34:40 -04:00
parent f877e0c558
commit 0084676bd5
Signed by: notohh
GPG key ID: BD47506D475EE86D
25 changed files with 95 additions and 1355 deletions

View file

@ -3,7 +3,7 @@ module.exports = {
browser: true, browser: true,
es2021: true es2021: true
}, },
extends: "eslint:recommended", extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
overrides: [ overrides: [
{ {
env: { env: {
@ -15,9 +15,11 @@ module.exports = {
} }
} }
], ],
parser: "@typescript-eslint/parser",
parserOptions: { parserOptions: {
ecmaVersion: "latest", ecmaVersion: "latest",
sourceType: "module" sourceType: "module"
}, },
plugins: ["@typescript-eslint"],
rules: {} rules: {}
}; };

View file

@ -1,21 +1,21 @@
import { App, Utils } from "./import.js"; const entry = App.configDir + "/ts/main.ts";
import { Bar } from "./js/main.js"; const outdir = "/tmp/ags/js";
const scss = App.configDir + "/main.scss"; try {
const css = App.configDir + "/style.css"; await Utils.execAsync([
"bun",
Utils.exec(`sass ${scss} ${css}`); "build",
entry,
function reloadCss() { "--outdir",
console.log("scss updating"); outdir,
Utils.exec(`sass ${scss} ${css}`); "--external",
App.resetCss(); "resource://*",
App.applyCss(css); "--external",
"gi://*"
]);
await import(`file://${outdir}/main.js`);
} catch (error) {
console.error(error);
} }
Utils.monitorFile(`${App.configDir}/scss`, reloadCss, "directory"); export {};
export default {
style: css,
windows: [Bar(2)]
};

View file

@ -1,23 +0,0 @@
import App from "resource:///com/github/Aylur/ags/app.js";
import * as Utils from "resource:///com/github/Aylur/ags/utils.js";
import Service from "resource:///com/github/Aylur/ags/service.js";
import Variable from "resource:///com/github/Aylur/ags/variable.js";
import Widget from "resource:///com/github/Aylur/ags/widget.js";
import Audio from "resource:///com/github/Aylur/ags/service/audio.js";
import Hyprland from "resource:///com/github/Aylur/ags/service/hyprland.js";
import Network from "resource:///com/github/Aylur/ags/service/network.js";
import SystemTray from "resource:///com/github/Aylur/ags/service/systemtray.js";
import Mpris from "resource:///com/github/Aylur/ags/service/mpris.js";
export {
App,
Audio,
Hyprland,
Mpris,
Network,
Service,
SystemTray,
Utils,
Variable,
Widget
};

View file

@ -1,35 +0,0 @@
import { Widget } from "../import.js";
import { Time } from "./widgets/time.js";
import { nixosLogo } from "./widgets/images/image.js";
import { Media } from "./widgets/music.js";
import { Workspaces } from "./widgets/hyprland.js";
const Start = () =>
Widget.Box({
hpack: "start",
children: [nixosLogo(), Workspaces()]
});
const Center = () =>
Widget.Box({
children: [Media()]
});
const End = () =>
Widget.Box({
hpack: "end",
children: [Time()]
});
const Bar = (monitor) =>
Widget.Window({
monitor,
name: `bar`,
anchor: ["top", "left", "right"],
exclusivity: "exclusive",
child: Widget.CenterBox({
startWidget: Start(),
centerWidget: Center(),
endWidget: End()
})
});
export { Bar };

View file

@ -1,19 +0,0 @@
import { Hyprland, Widget } from "../../import.js";
const Workspaces = () =>
Widget.Box({
class_name: "workspaces",
children: Hyprland.bind("workspaces").transform((ws) => {
return ws.map(({ id }) =>
Widget.Button({
on_clicked: () => Hyprland.sendMessage(`dispatch workspace ${id}`),
child: Widget.Label(`${id}`),
class_name: Hyprland.active.workspace
.bind("id")
.transform((i) => `${i === id ? "focused" : ""}`)
})
);
})
});
export { Workspaces };

View file

@ -1,8 +0,0 @@
import { Widget } from "../../../import.js";
const nixosLogo = () =>
Widget.Icon({
icon: "/home/notoh/snowflake/home/programs/ags/config/js/widgets/images/static/nixos.png"
});
export { nixosLogo };

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

View file

@ -1,20 +0,0 @@
import { Mpris, Widget } from "../../import.js";
const Media = () =>
Widget.Box({
class_name: "media",
child: Widget.Label("-").hook(
Mpris,
(self) => {
if (Mpris.players[0]) {
const { track_artists, track_title } = Mpris.players[0];
self.label = `${track_artists.join(", ")} - ${track_title}`;
} else {
self.label = "Nothing is playing";
}
},
"player-changed"
)
});
export { Media };

View file

@ -1,14 +0,0 @@
import { Utils, Widget } from "../../import.js";
const Time = () =>
Widget.Box({
child: Widget.Label({
className: "date"
}).poll(1000, (self) =>
Utils.execAsync(["date", "+%a %b %d %H:%M"]).then(
(time) => (self.label = time)
)
)
});
export { Time };

View file

@ -1,12 +0,0 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": ["node_modules", "**/node_modules/*"]
}

View file

@ -1,9 +0,0 @@
@import "scss/bar.scss";
@import "scss/general.scss";
@import "scss/widgets.scss";
* {
all: unset;
margin: 3px;
font-family: "Monaspace Krypton";
}

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,11 @@
{ {
"name": "snowflake-ags", "name": "snowflake-ags",
"version": "1.0.0", "version": "0.0.1",
"description": "snowflake ags", "description": "",
"main": "config.js", "main": "config.js",
"repository": { "scripts": {
"type": "git", "test": "echo \"Error: no test specified\" && exit 1"
"url": "https://git.flake.sh/notohh/snowflake"
}, },
"author": "notohh", "author": "notohh",
"license": "MIT", "license": "MIT"
"devDependencies": {
"eslint": "^8.56.0"
}
} }

View file

@ -1,5 +0,0 @@
@import "colors.scss";
window {
background-color: #000000;
}

View file

@ -1,24 +0,0 @@
/* tokyonight */
$red: #f7768e;
$orange: #ff9e64;
$yellow: #e0af68;
$light-green: #9ece6a;
$green: #73daca;
$turquoise: #89ddff;
$light-cyan: #b4f9f8;
$teal: #2ac3de;
$cyan: #7dcfff;
$blue: #7aa2f7;
$magenta: #bb9af7;
$white: #c0caf5;
$light-gray: #9aa5ce;
$parameters: #cfc9c2;
$comment: #565f89;
$black: #414868;
$foreground: #a9b1d6;
$foreground-highlight: #c0caf5;
$foreground-gutter: #363b54;
$background: #1a1b26;
$background-highlight: #30374b;
$background-menu: #16161e;

View file

@ -1,21 +0,0 @@
@import "colors.scss";
@mixin widget {
color: $white;
}
.date {
@include widget();
}
.workspaces {
@include widget();
}
.media {
@include widget();
}
image {
font-size: 24px;
}

View file

@ -0,0 +1 @@
@import "./style/main.scss";

View file

@ -0,0 +1,3 @@
* {
all: unset;
}

View file

@ -0,0 +1,48 @@
const scss = App.configDir + "/main.scss";
const css = App.configDir + "/style.css";
const time = Variable("", {
poll: [
1000,
function () {
return Date().toString();
}
]
});
Utils.monitorFile(
`${App.configDir}/style`,
function () {
const scss = `${App.configDir}/style.scss`;
const css = `./style.css`;
Utils.exec(`sass ${scss} ${css}`);
App.resetCss();
App.applyCss(css);
}
);
const Bar = (monitor: number) =>
Widget.Window({
monitor,
name: `bar${monitor}`,
anchor: ["top", "left", "right"],
exclusivity: "exclusive",
child: Widget.CenterBox({
start_widget: Widget.Label({
hpack: "center",
label: "Welcome to AGS!"
}),
end_widget: Widget.Label({
hpack: "center",
label: time.bind()
})
})
});
App.config({
style: css,
windows: [Bar(2)]
});

View file

@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"lib": ["ES2022"],
"allowJs": true,
"checkJs": true,
"strict": true,
"noImplicitAny": false,
"baseUrl": ".",
"typeRoots": ["./types"],
"skipLibCheck": true
}
}

View file

@ -0,0 +1 @@
/home/notoh/.local/share/com.github.Aylur.ags/types

View file

@ -9,7 +9,7 @@ in {
enable = true; enable = true;
extraPackages = with pkgs; [libsoup_3 libdbusmenu-gtk3]; extraPackages = with pkgs; [libsoup_3 libdbusmenu-gtk3];
}; };
home.packages = with pkgs; [dart-sass]; home.packages = with pkgs; [dart-sass bun];
xdg.configFile = { xdg.configFile = {
"ags".source = config.lib.file.mkOutOfStoreSymlink "${configDir}"; "ags".source = config.lib.file.mkOutOfStoreSymlink "${configDir}";
}; };