feat(astal): add basic working config
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
3a54b5f005
commit
e056756246
7 changed files with 120 additions and 10 deletions
47
modules/ags/astal/js/utils.js
Normal file
47
modules/ags/astal/js/utils.js
Normal 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
BIN
modules/ags/astal/package-lock.json
generated
Normal file
Binary file not shown.
5
modules/ags/astal/package.json
Normal file
5
modules/ags/astal/package.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"@girs/adw-1": "^1.4.3-3.2.9"
|
||||
}
|
||||
}
|
10
modules/ags/astal/scss/wim.scss
Normal file
10
modules/ags/astal/scss/wim.scss
Normal file
|
@ -0,0 +1,10 @@
|
|||
window {
|
||||
all: unset;
|
||||
}
|
||||
|
||||
|
||||
.base {
|
||||
background-color: #{"@window_bg_color"};
|
||||
border: 1px solid #{"@accent_bg_color"};
|
||||
padding: 5px;
|
||||
}
|
23
modules/ags/astal/tsconfig.json
Normal file
23
modules/ags/astal/tsconfig.json
Normal 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
20
modules/ags/astal/wim.ts
Normal 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',
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
|
@ -28,10 +28,21 @@ in {
|
|||
inherit (lib) optionals;
|
||||
|
||||
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
|
||||
agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types";
|
||||
agsConfigDir = ".nix/modules/ags/config";
|
||||
|
||||
configJs =
|
||||
/*
|
||||
javascript
|
||||
*/
|
||||
''
|
||||
import { transpileTypeScript } from './js/utils.js';
|
||||
|
||||
export default (await transpileTypeScript('${hostName}')).default;
|
||||
'';
|
||||
in {
|
||||
# Experimental Gtk4 ags
|
||||
programs.astal = {
|
||||
|
@ -46,19 +57,13 @@ in {
|
|||
home = {
|
||||
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;
|
||||
"${agsConfigDir}/types".source = agsTypes.source;
|
||||
"${agsConfigDir}/config.js".text =
|
||||
/*
|
||||
javascript
|
||||
*/
|
||||
''
|
||||
import { transpileTypeScript } from './js/utils.js';
|
||||
|
||||
export default (await transpileTypeScript('${hostName}')).default;
|
||||
'';
|
||||
"${agsConfigDir}/config.js".text = configJs;
|
||||
}
|
||||
// (import ./icons.nix {inherit pkgs agsConfigDir;});
|
||||
|
||||
|
|
Loading…
Reference in a new issue