feat(astal): add basic working config
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-03-22 23:31:37 -04:00
parent 3a54b5f005
commit e056756246
7 changed files with 120 additions and 10 deletions

View file

@ -0,0 +1,47 @@
const { execAsync, monitorFile } = Utils;
/** @param {string} host */
const watchAndCompileSass = (host) => {
const reloadCss = () => {
const scss = `${App.configDir}/scss/${host}.scss`;
const css = `/tmp/astal-${host}/style.css`;
execAsync(`sass ${scss} ${css}`).then(() => {
App.resetCss();
App.applyCss(css);
}).catch(print);
};
monitorFile(
`${App.configDir}/scss`,
reloadCss,
);
reloadCss();
};
/** @param {string} host */
export const transpileTypeScript = async(host) => {
const outPath = `/tmp/astal-${host}/index.js`;
await execAsync([
'bash', '-c',
// Create the dir if it doesn't exist
`mkdir -p /tmp/astal-${host}; ` +
`bun build ${App.configDir}/${host}.ts ` +
'--external resource:///* ' +
'--external gi://* ' +
'--external cairo ' +
'--external */fzf.es.js ' +
// Since bun wants to right in cwd, we just redirect stdin instead
`> ${outPath}`,
]).catch(print);
if (host !== 'greeter') {
watchAndCompileSass(host);
}
return await import(`file://${outPath}`);
};

BIN
modules/ags/astal/package-lock.json generated Normal file

Binary file not shown.

View file

@ -0,0 +1,5 @@
{
"devDependencies": {
"@girs/adw-1": "^1.4.3-3.2.9"
}
}

View file

@ -0,0 +1,10 @@
window {
all: unset;
}
.base {
background-color: #{"@window_bg_color"};
border: 1px solid #{"@accent_bg_color"};
padding: 5px;
}

View file

@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"lib": [
"ES2022"
],
"allowJs": true,
"checkJs": true,
"strict": true,
"noImplicitAny": false,
"baseUrl": ".",
"paths": {
"gi://Adw": ["./node_modules/@girs/adw-1/adw-1.d.ts"],
"gi://Adw?version=1": ["./node_modules/@girs/adw-1/adw-1.d.ts"]
},
"typeRoots": [
"./types",
"./node_modules"
],
"skipLibCheck": true
},
}

20
modules/ags/astal/wim.ts Normal file
View file

@ -0,0 +1,20 @@
import Adw from 'gi://Adw';
App.config({
windows: () => [
Widget.Window({
name: 'test',
child: Widget.Box({
setup: (self) => {
self.toggleCssClass('base');
},
child: new Adw.SplitButton({
label: 'test',
}),
}),
}),
],
});

View file

@ -28,10 +28,21 @@ in {
inherit (lib) optionals; inherit (lib) optionals;
astalTypes = config.home.file.".local/share/io.Aylur.Astal/types"; astalTypes = config.home.file.".local/share/io.Aylur.Astal/types";
astalConfigDir = ".nix/modules/ags/astal";
# https://github.com/Aylur/ags/blob/e1f2d311ceb496a69ef6daa6aebb46ce511b2f22/nix/hm-module.nix#L69 # https://github.com/Aylur/ags/blob/e1f2d311ceb496a69ef6daa6aebb46ce511b2f22/nix/hm-module.nix#L69
agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types"; agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types";
agsConfigDir = ".nix/modules/ags/config"; agsConfigDir = ".nix/modules/ags/config";
configJs =
/*
javascript
*/
''
import { transpileTypeScript } from './js/utils.js';
export default (await transpileTypeScript('${hostName}')).default;
'';
in { in {
# Experimental Gtk4 ags # Experimental Gtk4 ags
programs.astal = { programs.astal = {
@ -46,19 +57,13 @@ in {
home = { home = {
file = file =
{ {
".config/astal/types".source = astalTypes.source; ".config/astal".source = symlink /home/${mainUser}/.nix/modules/ags/astal;
"${astalConfigDir}/types".source = astalTypes.source;
"${astalConfigDir}/config.js".text = configJs;
".config/ags".source = symlink /home/${mainUser}/.nix/modules/ags/config; ".config/ags".source = symlink /home/${mainUser}/.nix/modules/ags/config;
"${agsConfigDir}/types".source = agsTypes.source; "${agsConfigDir}/types".source = agsTypes.source;
"${agsConfigDir}/config.js".text = "${agsConfigDir}/config.js".text = configJs;
/*
javascript
*/
''
import { transpileTypeScript } from './js/utils.js';
export default (await transpileTypeScript('${hostName}')).default;
'';
} }
// (import ./icons.nix {inherit pkgs agsConfigDir;}); // (import ./icons.nix {inherit pkgs agsConfigDir;});