78 lines
5.5 KiB
Markdown
78 lines
5.5 KiB
Markdown
# ANODE session autostart
|
|
|
|
ANODE supports i3-style session-specific autostart directives paired with per-profile overrides, `autostart.d/` drop-ins, and `ANODE`-filtered XDG `.desktop` entries.
|
|
|
|
## Startup lifecycle
|
|
|
|
- `anode-session` scrubs stale third-party DE environment variables, exports `XDG_CURRENT_DESKTOP=ANODE`, `XDG_SESSION_DESKTOP=anode`, `DESKTOP_SESSION=anode`, `XDG_SESSION_TYPE=x11`, and `ANODE_SESSION_PROFILE` when `--profile NAME` or `--profile=NAME` is passed, and supports `--replace` and `--no-autostart`.
|
|
- On first session launch, `anode-session` creates `~/.config/anode/autostart.d/` and copies `PREFIX/share/anode/autostart` (falling back to `data/autostart` in source checkouts) to `~/.config/anode/autostart` if absent.
|
|
- Unless `--no-autostart` is passed, once `dwm` advertises `_NET_SUPPORTING_WM_CHECK` whose `_NET_WM_NAME` contains `ANODE` (polled with `xprop` for up to 5 s, falling back to `sleep 1`), `anode-session` launches `anode-autostart start` in the background.
|
|
- Pressing `Mod4 + Shift + r` (`reloadxres` with `arg->i = 1`) or sending `SIGHUP` to `dwm` (live `execvp` restart carrying `ANODE_DWM_RESTARTED=1`) triggers `anode-autostart reload`, re-running only `exec_always` entries. Background theme/DPI reloads via `SIGUSR1` or `XA_RESOURCE_MANAGER` pass `NULL` and do not re-trigger `anode-autostart reload`.
|
|
|
|
## Declarative directives
|
|
|
|
Declarative rules live in `~/.config/anode/autostart` (or the file passed via `--config FILE`). Blank lines and lines starting with `#` are ignored, and `--no-startup-id` is accepted for i3 compatibility.
|
|
|
|
| Directive | Behavior |
|
|
|---|---|
|
|
| `exec [--no-startup-id] <command>` | Run `<command>` once during `anode-autostart start` |
|
|
| `exec_once [--no-startup-id] <command>` | Run `<command>` during `start` only when no matching UID-owned process is already running in the current `XDG_SESSION_ID` / D-Bus session (checked via POSIX `ps` and `/proc/<pid>/environ` when available) |
|
|
| `exec_always [--no-startup-id] <command>` | Run `<command>` during `start` and re-run on `anode-autostart reload` (`Mod4 + Shift + r` or `SIGHUP` restart) |
|
|
| `include <path>` | Load directives from another file (absolute path, `~/...`, or relative to the current file; duplicate/cyclic includes are skipped, and nesting deeper than 8 levels fails `check`) |
|
|
|
|
> [!NOTE]
|
|
> On Linux (`/proc/<pid>/environ`), `exec_once` compares `XDG_SESSION_ID` and `DBUS_SESSION_BUS_ADDRESS` against the running session so orphaned background processes left behind by dead or separate login sessions (such as `pipewire` or `redshift` across `elogind` or LightDM logins) do not suppress startup in a fresh ANODE session.
|
|
|
|
## Session profiles
|
|
|
|
Passing `--profile NAME` or `--profile=NAME` to `anode-session` or `anode-autostart` (or exporting `ANODE_SESSION_PROFILE=NAME`) loads `~/.config/anode/autostart.<profile>` (or `PREFIX/share/anode/autostart.<profile>` if no user file exists) immediately after the base `autostart` file:
|
|
|
|
```sh
|
|
# ~/.xinitrc
|
|
exec /usr/local/bin/anode-session --profile work
|
|
```
|
|
|
|
## Drop-ins & XDG autostart
|
|
|
|
During `start` (never during `reload`), `anode-autostart` also evaluates drop-in scripts/desktop files and XDG autostart directories:
|
|
|
|
- **Drop-in directories**: `$XDG_CONFIG_HOME/anode/autostart.d/` followed by `$ANODE_PREFIX/share/anode/autostart.d/`. Earlier basenames shadow later ones; regular executable files are executed directly, and `*.desktop` files follow desktop-entry filtering.
|
|
- **XDG autostart directories**: `$XDG_CONFIG_HOME/autostart/*.desktop` followed by each directory in `$XDG_CONFIG_DIRS` (default `/etc/xdg/autostart/*.desktop`). Earlier basenames shadow later ones, so placing a `.desktop` file with `Hidden=true` in `~/.config/autostart/` masks the corresponding system entry.
|
|
- **Desktop-entry filtering**: Honors `Hidden=true`, case-insensitive `OnlyShowIn` / `NotShowIn` matching against `$XDG_CURRENT_DESKTOP`, `TryExec` binary lookup, `Terminal=true` execution via `st -e <command>`, and stripping of `%f`/`%F`/`%u`/`%U`/`%d`/`%D`/`%n`/`%N`/`%i`/`%c`/`%k`/`%v`/`%m` field codes (`%%` is unescaped to `%`).
|
|
- **Disabling XDG autostart**: Pass `--no-xdg` or set `ANODE_XDG_AUTOSTART=0` to skip XDG `.desktop` discovery while keeping declarative configs and `autostart.d/` drop-ins active.
|
|
|
|
## Command-line usage
|
|
|
|
Syntax: `anode-autostart [start|reload|list|check] [OPTIONS]`
|
|
|
|
| Argument / flag | Behavior |
|
|
|---|---|
|
|
| `start` | Default subcommand; run `exec`, `exec_once`, `exec_always`, `autostart.d/`, and XDG entries |
|
|
| `reload` | Run only `exec_always` directives (invoked by `dwm` on `Mod4 + Shift + r` and `SIGHUP` restart) |
|
|
| `list` | Print resolved commands and drop-ins without executing them |
|
|
| `check` | Validate declarative configs and `include` chains (exits `0` on valid, non-zero on error) |
|
|
| `--config FILE` / `--config=FILE` | Use `FILE` instead of `~/.config/anode/autostart` |
|
|
| `--profile NAME` / `--profile=NAME` | Load profile overrides from `autostart.NAME` |
|
|
| `--no-xdg` | Skip `$XDG_CONFIG_HOME/autostart` and `$XDG_CONFIG_DIRS/autostart` entries |
|
|
| `--dry-run` | Print `[exec]`, `[exec_once]`, `[exec_always]`, `[script]`, and `[desktop]` actions without launching |
|
|
|
|
```sh
|
|
anode-autostart check
|
|
anode-autostart list --profile work
|
|
anode-autostart reload --dry-run
|
|
```
|
|
|
|
## Example configuration
|
|
|
|
```sh
|
|
# ~/.config/anode/autostart
|
|
include ~/.config/anode/local.conf
|
|
|
|
exec_always --no-startup-id xset r rate 260 35
|
|
exec_always --no-startup-id sh -c '[ -r ~/.wallpaper ] && feh --bg-fill ~/.wallpaper'
|
|
|
|
exec_once --no-startup-id nm-applet
|
|
exec_once --no-startup-id picom
|
|
exec notify-send "ANODE" "Session ready"
|
|
```
|