Skip to content

Commit e9722d5

Browse files
committed
update wiki for 1.7.4
1 parent 952fb0c commit e9722d5

24 files changed

+461
-389
lines changed

src/content/docs/config/app.md

-5
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ This is the main `Gtk.Application` instance that is running.
3030
## Window toggled signal
3131

3232
```js
33-
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
34-
import App from 'resource:///com/github/Aylur/ags/app.js';
35-
3633
// this is only signaled for windows exported in config.js
3734
// or added with App.addWindow
3835
const label = Widget.Label()
@@ -47,8 +44,6 @@ const label = Widget.Label()
4744
If you want to change the style sheet on runtime
4845

4946
```js
50-
import App from 'resource:///com/github/Aylur/ags/app.js';
51-
5247
// if you apply multiple, they are all going to apply on top of each other
5348
App.applyCss('path-to-file');
5449

src/content/docs/config/cli.md

+14-23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: CLI
3+
description: Command Line Interface and running files
34
---
45

5-
```bash
6+
```sh
67
$ ags --help
78

89
USAGE:
@@ -18,7 +19,8 @@ OPTIONS:
1819
-t, --toggle-window Show or hide a window
1920
-r, --run-js Execute string as an async function
2021
-f, --run-file Execute file as an async function
21-
--clear-cache Remove $HOME/.cache/ags
22+
-I, --init Initialize the configuration directory
23+
-C, --clear-cache Remove $HOME/.cache/ags
2224

2325
```
2426

@@ -69,8 +71,7 @@ With `--run-js` it is possible to execute code when `ags` is already running.
6971
It is useful for: calling Service methods, updating Variable values,
7072
debugging or anything else.
7173
`--run-js` expects a string which will be the body of an *async function*
72-
executed relative to `app.ts`. This is important because of how you
73-
can import modules inside this function.
74+
executed relative to `app.ts`.
7475

7576
If there is no `;` character in the string, `return` keyword will be inserted automatically
7677

@@ -104,36 +105,26 @@ return 'hello from a file'
104105
```
105106

106107
:::info
107-
Since `--run-js` is the body of a function, you can't use top level imports
108+
Since `--run-js` is the body of a function, you can't use top level static imports
108109
:::
109110

110-
This will throw an error
111-
112-
```js
113-
#!/usr/bin/env -S ags --run-file
114-
import App from 'resource:///com/Aylur/github/ags/app.js'
115-
```
111+
:::important
112+
The function gets executed relative to `app.ts`, which means
113+
importing a module from your config needs a full path.
114+
:::
116115

117-
You can use `import` as a method however
116+
this throws
118117

119118
```js
120119
#!/usr/bin/env -S ags --run-file
121-
const App = (await import(
122-
'resource:///com/Aylur/github/ags/app.js',
123-
)).default;
120+
import Module from 'file:///path/to/file.js' // throws
124121
```
125122

126-
:::tip
127-
The function gets executed relative to `app.ts`,
128-
meaning `resource:///com/Aylur/github/ags` can be substituted as `.`
129-
This also means importing a module from your config needs a full path.
130-
:::
123+
You can use `import` as an **async** method
131124

132125
```js
133126
#!/usr/bin/env -S ags --run-file
134-
const App = (await import('./app.js')).default;
135-
136-
const File = await import(`file:///path/to/file.js`);
127+
const Module = (await import('file:///path/to/file.js')).default;
137128
```
138129

139130
## Examples

src/content/docs/config/common-issues.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Common Issues
3-
description: Common Issues and Tips & Trick
3+
description: Common Issues and Tips & Tricks
44
---
55

66
## Window doesn't show up
@@ -24,9 +24,10 @@ Widget.Window({
2424
## Custom svg symbolic icons
2525

2626
Put svgs in a directory, named `<icon-name>-symbolic.svg`
27-
and use `Gtk.IconTheme.append_search_path`
27+
and use `Gtk.IconTheme.append_search_path` or `icons` option in exported object
2828

2929
```js
30+
// config.js
3031
import Gtk from 'gi://Gtk?version=3.0';
3132

3233
Gtk.IconTheme.get_default().append_search_path(`${App.configDir}/assets`);
@@ -35,4 +36,8 @@ Widget.Icon({
3536
icon: 'custom-symbolic', // custom-symbolic.svg
3637
css: 'color: green;', // can be colored, like other named icons
3738
});
39+
40+
export default {
41+
icons: `${App.configDir}/assets`,
42+
}
3843
```
+14-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Config Object
3+
description: Exported configuration object
34
---
45

56
When you start `ags`, it will try to `import` the `default` `export`
@@ -10,36 +11,30 @@ the config **will not be reloaded**.
1011
```js
1112
// config.js
1213
export default {
14+
style: './style.css',
15+
icons: './assests',
16+
windows: [
17+
// Array<Gtk.Window>
18+
],
1319
closeWindowDelay: {
1420
'window-name': 500, // milliseconds
1521
},
16-
notificationPopupTimeout: 5000, // milliseconds
17-
notificationForceTimeout: false,
18-
cacheNotificationActions: false,
19-
maxStreamVolume: 1.5, // float
20-
cacheCoverArt: true,
21-
2222
onConfigParsed: function() {
2323
// code that runs after this object is loaded
24-
}
25-
26-
style: App.configDir + '/style.css',
27-
windows: [
28-
// Array<Gtk.Window>
29-
],
24+
},
25+
onWindowToggled: function (windowName, visible) {
26+
print(`${windowName} is ${visible}`)
27+
},
3028
};
3129
```
3230

3331
## The exported config object
3432

3533
| Field | Type | Description |
3634
|-------|------|-------------|
37-
| `closeWindowDelay` | `Record<string, number>` | Delays the closing of a window, this is useful for making animations with a revealer
38-
| `notificationPopupTimeout` | `number` | How long should a notification be flagged for popup
39-
| `notificationForceTimeout` | `boolean` | Force `notificationPopupTimeout` and ignore timeout set by notifications
40-
| `cacheNotificationActions` | `boolean` | Whether to cache notification actions, so that they can be reloaded
41-
| `maxStreamVolume` | `number` | Maximum possible volume on an Audio Stream
42-
| `cacheCoverArt` | `boolean` | Whether to cache mpris cover arts. `true` by default
43-
| `onConfigParsed` | `(app: App) => void` | Callback to execute after all user modules were resolved.
4435
| `style` | `string` | Path to a css file.
36+
| `icons` | `string` | Icon directory to append to Gtk.IconTheme.
4537
| `windows` | `Array<Gtk.Window>` | List of [Windows](./widgets#window).
38+
| `closeWindowDelay` | `Record<string, number>` | Delays the closing of a window, this is useful for making animations with a revealer
39+
| `onConfigParsed` | `(app: App) => void` | Callback to execute after all user modules were resolved.
40+
| `onWindowToggled` | `(windowName: string, visible: boolean) => void` | Callback to execute when a window is toggled.

src/content/docs/config/custom-service.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
---
22
title: Custom Service
3+
description: Writing Custom Services
34
---
45

6+
Writing a custom Service is as simple as
7+
8+
- declaring a class
9+
- defining its signals and properties
10+
- declaring get/set for properties
11+
512
This is an example Service for backlight using `brightnessctl`
613
to set the brightness and `Utils.monitorFile` to watch for changes.
714

815
```js
916
// brightness.js
10-
import Service from 'resource:///com/github/Aylur/ags/service.js';
11-
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
12-
1317
class BrightnessService extends Service {
1418
// every subclass of GObject.Object has to register itself
1519
static {
@@ -105,17 +109,16 @@ For `bind` to work, the property has to be defined in `Service.register`
105109
Using it with widgets is as simple as using the builtin ones.
106110

107111
```js
108-
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
109-
import Brightness from './brightness.js';
112+
import brightness from './brightness.js';
110113

111114
const slider = Widget.Slider({
112-
on_change: self => Brightness.screen_value = self.value,
113-
value: Brightness.bind('screen-value'),
115+
on_change: self => brightness.screen_value = self.value,
116+
value: brightness.bind('screen-value'),
114117
});
115118

116119
const label = Label({
117-
label: Brightness.bind('screen-value').transform(v => `${v}`),
118-
setup: self => self.hook(Brightness, (self, screenValue) => {
120+
label: brightness.bind('screen-value').transform(v => `${v}`),
121+
setup: self => self.hook(brightness, (self, screenValue) => {
119122
// screenValue is the passed parameter from the 'screen-changed' signal
120123
self.label = screenValue ?? 0;
121124

@@ -124,9 +127,9 @@ const label = Label({
124127
// the passed screenValue will be undefined the first time
125128

126129
// all three are valid
127-
self.label = `${Brightness.screenValue}`;
128-
self.label = `${Brightness.screen_value}`;
129-
self.label = `${Brightness['screen-value']}`;
130+
self.label = `${brightness.screenValue}`;
131+
self.label = `${brightness.screen_value}`;
132+
self.label = `${brightness['screen-value']}`;
130133

131134
}, 'screen-changed'),
132135
});

0 commit comments

Comments
 (0)