From 13b6c88dd090bfc8997a2916f0c0cc44bdce2c74 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 7 Sep 2024 13:00:42 +0000 Subject: docs: touchups * code block langs * ags faq * fix broken links --- docs/ags/cli-app.md | 38 +++++++++++++----------- docs/ags/faq.md | 76 ++++++++++++++++++++++++++++++++++++++++++------ docs/ags/installation.md | 14 ++++----- docs/ags/theming.md | 6 ++-- docs/ags/utilities.md | 30 +++++++++---------- docs/ags/widget.md | 53 ++++++++++++++++++++++++++++----- 6 files changed, 158 insertions(+), 59 deletions(-) (limited to 'docs/ags') diff --git a/docs/ags/cli-app.md b/docs/ags/cli-app.md index e647fbf..ceed56a 100644 --- a/docs/ags/cli-app.md +++ b/docs/ags/cli-app.md @@ -2,7 +2,7 @@ `App` is a singleton **instance** of [Astal.Application](https://aylur.github.io/libastal/class.Application.html). -```tsx +```ts import { App } from "astal" ``` @@ -29,7 +29,7 @@ You can not instantiate widgets outside of the main function. You can run multiple instance by defining a unique instance name. -```tsx +```ts App.start({ instanceName: "my-instance", // defaults to "astal" main() {}, @@ -52,16 +52,20 @@ App.start({ }) ``` -```bash -# ags cli -$ ags -m "say hi" -hi cli +:::code-group -# astal cli -$ astal say hi -hi cli +```sh [ags] +ags -m "say hi" +# hi cli ``` +```sh [astal] +astal say hi +# hi cli +``` + +::: + If you want to run arbitrary JavaScript from cli, you can use `App.eval`. It will evaluate the passed string as the body of an `async` function. @@ -76,19 +80,19 @@ App.start({ If the string does not contain a semicolon, a single expression is assumed and returned implicity. -```bash -$ ags -m "'hello'" -hello +```sh +ags -m "'hello'" +# hello ``` If the string contains a semicolon, you have to return explicitly -```bash -$ ags -m "'hello';" -undefined +```sh +ags -m "'hello';" +# undefined -$ ags -m "return 'hello';" -hello +ags -m "return 'hello';" +# hello ``` ## App without AGS diff --git a/docs/ags/faq.md b/docs/ags/faq.md index 0e71516..baf9d6c 100644 --- a/docs/ags/faq.md +++ b/docs/ags/faq.md @@ -8,7 +8,7 @@ a `Gdk.Monitor` object which you can get from compositor libraries. Example with Hyprland -```js +```tsx import Hyprland from "gi://AstalHyprland" function Bar(gdkmonitor) { @@ -28,7 +28,7 @@ App.start({ main }) JavaScript is **not** an bash. -```tsx +```ts const HOME = exec("echo $HOME") // does not work ``` @@ -39,7 +39,7 @@ to the `echo` program. :::danger Please don't do this You could pass it to bash, but that is a horrible approach. -```tsx +```ts const HOME = exec("bash -c 'echo $HOME'") ``` @@ -47,7 +47,7 @@ const HOME = exec("bash -c 'echo $HOME'") You can read environment variables with [GLib.getenv](https://gjs-docs.gnome.org/glib20~2.0/glib.getenv). -```tsx +```ts import GLib from "gi://GLib" const HOME = GLib.getenv("HOME") @@ -58,8 +58,9 @@ const HOME = GLib.getenv("HOME") Put the svgs in a directory, named `-symbolic.svg` and use `App.add_icons` or `icons` parameter in `App.start` -```js -// app.ts +:::code-group + +```ts [app.ts] App.start({ icons: `${SRC}/icons`, main() { @@ -71,6 +72,8 @@ App.start({ }) ``` +::: + :::info If there is a name clash with an icon from your current icon pack the icon pack will take precedence @@ -82,7 +85,7 @@ The `console` API in gjs uses glib logging functions. If you just want to print some text as is to stdout use the globally available `print` function or `printerr` for stderr. -```js +```ts print("print this line to stdout") printerr("print this line to stderr") ``` @@ -91,7 +94,7 @@ printerr("print this line to stderr") The `bind` function can take two types of objects. -```typescript +```ts interface Subscribable { subscribe(callback: (value: T) => void): () => void get(): T @@ -108,7 +111,7 @@ and custom objects. For example you can compose `Variables` in using a class. -```typescript +```ts type MyVariableValue = { number: number string: string @@ -154,3 +157,58 @@ function MyWidget() { return