Skip to content

Placeholders ​

Templates in [templates] and [[rules]] substitute values from the current touch request. [[rules]] match on the same names.

Template syntax ​

Templates use Jinja syntax, rendered by MiniJinja. Earlier versions of touchcue used single braces, as in {app.name|"An application"}; such a template is now a configuration error. A placeholder namespace.field from the table below is written as an attribute, such as app.name:

text
{{ request.method }}                               the value of a placeholder
{{ app.name or process.name or "An application" }} the first value that is not empty, else the literal
{{ requester.name }}{% if app.name %} ({{ app.name }}){% endif %}
                                                   text only when a value is not empty
{% if request.method == "openpgp" %}…{% else %}…{% endif %}
                                                   a branch
{{ requester.name | upper }}                       a filter
{%- if app.name %} … {% endif -%}                  - removes the whitespace before or after a block
{% raw %}{{ }}{% endraw %}                         literal braces
  • Every value is a string. A value that is not known is undefined: it renders empty and is false, and so is an empty string. app.name renders empty when there is no application.
  • Comparisons compare strings, as in request.count == "2". Convert with int to compare numbers: request.count | int > 1. A comparison printed directly renders True or False.
  • The built-in filters and tests are available, for example the filters upper, lower, title, capitalize, trim, replace, default, first, length and int, and the tests defined, startingwith, endingwith and in. The filters format, indent, slice and batch are not available. Of the global functions, range, dict and namespace are available. Methods, as in app.name.upper(), are not: use a filter.
  • {% set %}, {% with %}, {% for %} and {% filter %} work. Macros, include, extends and import do not: they are syntax errors.
  • Whitespace is kept as written, except that one trailing newline of the template is removed. A - inside a block's delimiter, as in {%-, -%}, {{- or -}}, removes the whitespace, newlines included, on that side of the block; this helps in templates written as multi-line TOML strings.
  • The output is plain text and is not HTML-escaped.

When the configuration is loaded, a syntax error or an unknown name is a configuration error that points at the offending text. A name is known when it is a placeholder written namespace.field, a name the template sets with set, with or for, or one of the global functions above. A whole namespace, as in {{ app }} or app["name"], is unknown: write app.name.

A failure that only shows while rendering does not lose the prompt. Such failures are an unknown filter or test, an operation on values of the wrong type as in request.count + 1, a render that runs more than 1,000 instructions or writes more than 64 KiB, and a render that takes longer than 200 ms. A failed rule template is replaced by the [templates] template, and that by the built-in default; a render that takes too long uses the built-in defaults. The daemon logs the failed template's name and the error, at most once a minute per template.

Templates are trusted configuration, written by the owner of the configuration file. The limits above bound the number of instructions and the output of a render, not the time or memory a single instruction takes: an expression such as "x" * 100000000 builds a string of 100 MB, and joining strings with ~ in a loop can double one at each step. A render that does not finish keeps running in the background; until it ends, every prompt uses the built-in templates and the daemon logs a warning at most once a minute.

Names ​

NamespaceFields
appname, id, icon, exe, pid, cmdline, wm_class, container
processname, exe, pid, cmdline, uid, chain
requestername, exe, pid, label
devicevendor, model, product, vid, pid, kind, transport
requestmethod, op, action, source, class, confidence, elapsed, count, state, detail

process is the client process that talks to the device or to gpg-agent, such as gpg or ssh-sk-helper. requester is the program that asked it to, such as claude running git commit -S. app is the desktop application they run in, such as Kitty. A value that is not known is empty, so give a fallback, as in {{ requester.label or process.name or "An application" }}.

process.name is the client's comm. requester.name and the names in process.chain are the process's comm, else its executable's file name. process.chain lists the names from the client up to the application's process, client first, for example gpg ← git ← bash ← claude ← nu ← kitty: at most 8 names of at most 32 characters each. A longer chain keeps the first 7 names and the last, with … between them, as in gpg ← git ← bash ← claude ← nu ← herdr ← herdr ← … ← kitty.

Requester ​

The requester is the program you started inside the application: touchcue walks the parent processes from the application's process down to the client and takes the first process that is not on the skip list. By default the skip list holds shells, terminal multiplexers, command wrappers such as sudo, env and timeout, and service managers. The application's own processes, those running its executable, and processes of other users are always passed over, and when every process is passed over, the requester is the client, or nobody when the client is the application itself. requester.skip replaces the list, requester.extend_skip adds to it, and touchcue check prints the list and how it reads its own terminal.

Process tree, client firstrequester.label
gpg ← git ← bash ← claude ← nu ← herdr ← herdr ← nu ← kitty, Claude Code in herdrclaude in kitty
gpg ← git ← zsh ← kitty, git commit -S typed in a shellgit in kitty
ssh-sk-helper ← ssh ← zsh ← kitty, ssh typed in a shellssh in kitty
gpg ← git ← sh ← make ← bash ← claude ← nu ← kittyclaude in kitty
gpg ← jj ← claude ← nu ← kitty, or pass in place of jjclaude in kitty
gpg ← git ← release.sh ← zsh ← kitty, a script run by bashrelease.sh in kitty
gpg ← timeout ← zsh ← kittygpg in kitty
git ← nu ← code ← code, the terminal of Visual Studio Codegit in Visual Studio Code
firefox, holding the FIDO device itselfFirefox
ssh ← restic ← backup.sh ← systemd, without an applicationbackup.sh
sudo ← zsh ← kitty, with sudo as the clientsudo in kitty
gpg ← git ← claude ← zsh ← nvim ← zsh ← kitty, Claude Code in a Neovim terminalnvim in kitty; with extend_skip = ["nvim"], claude in kitty

Names are matched against the skip list by comm, else by the executable's file name when comm cannot be read. Matching is exact and case-sensitive, an entry ending in * is a prefix, and comm holds at most 15 bytes, so a longer name needs a prefix entry. requester.* is empty when there is no requester; when the application is found through its systemd unit, the application end of the walk is the topmost process of that unit, the one that started the application. The walk stops at the first process whose names cannot be read or whose pid was reused; the requester is then the best guess among the processes read before it.

requester.label combines both names: <requester.name> in <app.name> (w instead of in in Polish) when both are known and differ other than in ASCII case, otherwise whichever of app.name and requester.name is known, and empty when neither is. It is at most 260 characters. Like the names it is built from, it is published to IPC clients and hooks.

Limits:

  • A program that runs a terminal, such as Neovim's :terminal, is named instead of what runs in that terminal. Add it to extend_skip.
  • A script keeps its own name only when it is run through its shebang line, as ./release.sh, and that line names the interpreter directly, as #!/bin/bash. Run as bash release.sh, or with #!/usr/bin/env bash, its comm is bash and it is skipped like a shell.
  • A daemonized tmux server is reparented away from the terminal, so commands run inside it are found without the application.
  • Like app, the requester is a claim: any process of the same user can choose its comm, for example to be skipped, and the request is then attributed to the process above it.

Values ​

NameValues
request.methodfido2, u2f, openpgp
request.opsign, decrypt, auth for OpenPGP; empty for FIDO
request.actionwhat the request waits for, worded for people; see below
request.sourcefido; for OpenPGP ssh when an auth operation runs while a client is connected to gpg-agent's ssh socket, else gpg
request.classasserted for FIDO, activity for OpenPGP
request.statewaiting, touched, cancelled, failed, timed_out
request.confidencehigh, medium, low
request.elapsedwhole seconds since the request started
request.countnumber of client attempts merged into this request, starting at 1
request.detailextra text from a reporter, at most 200 characters
device.kindfido, openpgp
device.transportusb, bluetooth, nfc, other
device.vid, device.pidUSB vendor and product id, four lowercase hex digits
device.vendorvendor name, for example Yubico; for an OpenPGP card, its manufacturer

request.confidence is high when one process holds the FIDO device open, or when an OpenPGP request is the next OpenPGP card operation within 30 s after a confirmed pinentry PIN or confirmation dialog whose client is still connected to gpg-agent (see GPG); medium when several processes hold the FIDO device open or when the client is otherwise chosen among the clients of gpg-agent for an OpenPGP request; and low otherwise.

request.action words request.method and request.op for the default body, in the language of locale. Rules and hooks should compare request.method, request.op and request.source, whose values stay fixed; the wording and language of request.action may change.

RequestEnglishPolishGerman
FIDO2 or U2Fa passkeypotwierdzenie kluczem dostępueine Bestätigung per Passkey
OpenPGP signa GPG signaturepodpis GPGdas Signieren mit GPG
OpenPGP decryptGPG decryptionodszyfrowanie GPGdas Entschlüsseln mit GPG
OpenPGP authGPG authenticationuwierzytelnienie GPGdie Authentifizierung mit GPG
OpenPGP with source sshan SSH loginlogowanie przez SSHeine SSH-Anmeldung
other OpenPGP operationsa GPG operationoperację GPGeinen GPG-Vorgang

The Polish and German wordings follow czeka na and wartet auf in the default body, so they are in the accusative case.

The FIDO source cannot tell a sign-in from a registration. An OpenSSH security key is a FIDO request too; a rule matching requester.name = "ssh" can word it differently.

request.detail is empty unless a reporter sent it. touchcue askpass sets it for OpenSSH security keys, for example ED25519-SK SHA256:… → user git; see OpenSSH security keys.

There is no device.serial.