The login service

Have the system start a session when you log in and start it again if it stops, with launchd on macOS or a systemd user service on Linux.

What it is for

Normally a session's server is started by the first astrum that asks for it, and runs until it is stopped. Running it as a login service hands it to the system's own service manager instead:

It is optional. Nothing else about using Astrum changes: you attach with astrum as before, and detach as before.

macOSLinux
Service managerlaunchd, as a launch agentsystemd, as a user service
The file it writes~/Library/LaunchAgents/io.github.robert-mcdermott.astrum.<session>.plist~/.config/systemd/user/astrum-<session>.service
Startedwhen you log inwhen your user's systemd starts: at login, or at boot with lingering on
Through a logoutno: macOS ends every process of yours; the session comes back restored at the next loginyes, with lingering on
The server's own log~/.local/share/astrum/service-<session>.logthe user journal

Setting it up

astrum service install

sets up the service for the default session and starts it. Add -s name for another session; each session has a service of its own.

On Linux it says something like:

Installed /home/me/.config/systemd/user/astrum-default.service
Session `default` now starts when you log in, and starts again if it stops.
To keep it running while you are logged out as well, turn on lingering:
    loginctl enable-linger

On macOS it says the session now starts when you log in, and that logging out of macOS still ends it.

If the session is already running, started the ordinary way, it is left as it is. The service takes over the next time the session is stopped (astrum kill), and its tabs come back.

Running astrum service install again when nothing has changed says the service is already installed and up to date, and touches nothing. When something has changed (you moved Astrum, say), the file is written again and the session restarted to take the change, and its tabs come back. Run it from a terminal outside that session: a restart would cut off a command running inside it, so Astrum refuses there and says why.

Seeing what it would write

astrum service install --print

prints where the file would go and everything that would be in it, and does nothing else. Add -s name to see another session's.

What it changes

On macOS

On Linux

Either way

Staying up through a logout on Linux

Without lingering, systemd stops a user's services at their last logout, and the session stops with them; its tabs come back at the next login. With lingering on, your user's systemd keeps running while you are logged out (and starts when the machine does), so the session stays up:

loginctl enable-linger

astrum service install and astrum service status both say when lingering is off. loginctl disable-linger turns it off again.

The environment it has

A server started by the service manager does not come from one of your shells, so it has a bare environment. Astrum hands it only what a session needs to find its files and start your shell, as they are in the terminal you run install from: SHELL, LANG, LC_ALL, LC_CTYPE, XDG_CONFIG_HOME, XDG_DATA_HOME, ASTRUM_CONFIG_DIR, ASTRUM_DATA_DIR, ASTRUM_RUNTIME_DIR and ASTRUM_KEYCHAIN_FILE. If none of the language settings is set, it is given a UTF-8 one, so that shells do not garble anything beyond plain ASCII.

What that means:

Checking on it

astrum service status

says whether the service for the session is installed, and whether it is running:

Service for session `default`: running
/home/me/.config/systemd/user/astrum-default.service

or installed, not running, or that no service is installed for the session. On Linux it also says when lingering is off. astrum ls lists the session as usual once it is running.

The system's own tools see it too: launchctl print gui/$(id -u)/io.github.robert-mcdermott.astrum.default on macOS, and systemctl --user status astrum-default.service on Linux.

Removing it

astrum service uninstall

removes the service's file, tells the service manager it is gone, and stops the session. Its tabs are kept, and come back the next time you start it with astrum, the ordinary way. Add -s name for another session's service.

Run it from a terminal outside that session: stopping the session would cut the command off half-way, so Astrum refuses to run it inside and says why. The file goes before the session is stopped, so even a command that was cut off cannot leave the service to come back at the next login.

Things to know