1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
[Unit]
Description=mastodon-alt-text alt text picker
# Started on demand by `mastodon-alt-text` (which does `systemctl --user
# restart`), never by a target. Hence no [Install] section: enabling it would
# only start a server with nothing to caption.
After=graphical-session.target
[Service]
# notify, so that `systemctl restart` only returns once the port is accepting.
# The launcher spawns the browser right afterwards and relies on this; without
# it the first request would race the listener.
Type=notify
NotifyAccess=main
# Let pass(1)/gpg find the keyring and agent to decrypt the Gemini API key.
Environment="GNUPGHOME=%h/.gnupg"
# No port is specified: the server binds an ephemeral one and writes it to
# $XDG_RUNTIME_DIR/mastodon-alt-text.port, which the launcher reads. A fixed
# port would be a reservation in a shared namespace for a window that exists
# for a couple of minutes, and would collide with whatever else had taken it.
ExecStart=%h/.nix-profile/bin/mastodon-alt-text serve --idle=60s
# One shot per invocation: if generation fails, the error belongs on screen in
# the browser window, not in a restart loop.
Restart=no
# REQUIRED, not hardening. xclip does not write the clipboard and exit: X11
# selections are owned by a live process that serves the data on request, so
# xclip forks and stays resident. Under the default KillMode=control-group
# systemd SIGKILLs that process along with the server at shutdown, and the
# alt text you picked silently vanishes from the clipboard ~a minute later.
# KillMode=process kills only the main process and lets the selection owners
# outlive it.
KillMode=process
|