skil.li

How a skillie runs

What skil.li does when a skillie runs, whoever started it (the launcher, a key, Ask, an agent, a link, the menu bar).

Before it starts

  1. Confirmation. With @skilli.needsConfirmation true, the card asks "Run “…”?" first, every time (inline line reads excepted). Without it, a link asks first, unless you chose Always for that skillie with those arguments; a skillie that asks by itself is not asked twice, and offers no Always.
  2. Arguments.
    • From the launcher, each is asked in turn.
    • From a link with fewer values than required, the launcher asks for all of them (the link's values are not kept). arg= with nothing after it passes an empty value.
    • From a key: a skillie with a required argument opens the launcher on its first one, as from the launcher; one whose arguments are all optional (or that has none) runs at once, with empty strings.
    • An agent calling run_skillie without a required one gets an error naming it.

The process

WhatValue
ProgramThe file itself when it is executable. Otherwise the interpreter its first line names (#!/usr/bin/env python3 → /usr/bin/env python3 <file>); the #! must name an absolute path.
ArgumentsOne per declared argument, in order ($1, $2, $3 / sys.argv[1:] / process.argv.slice(2)), empty strings for optional ones left empty, percent-encoded where asked.
Folder@skilli.currentDirectoryPath (with ~ expanded), else the script's own folder.
Standard inputEmpty (/dev/null): a script that reads stdin gets end of file at once.
OutputStandard output and standard error together, as one text. Terminal colour codes are taken out.
Environmentskil.li's own environment, with the changes below.
Time limit120 seconds by default (recording skillies can declare a longer limit); 10 seconds for an inline line read by itself (launcher row, menu bar).
Exit status0: success. Anything else: the card shows it as a failure.

Environment

The time limit

An automatic recording skillie with an extended limit may run again after skil.li restarts if its last run did not succeed. Recovery waits for the previous process group to exit. Make repeated runs safe. While it runs, the recording window and menu bar show its status. The recorder shows its result when the run ends.

At the limit, skil.li sends SIGTERM to the skillie and every process still in its process group (what it started, unless one moved to a group of its own, as setsid does), then SIGKILL three seconds later. A "$SKILLI_CLI" call the skillie was waiting for stops with it, and a question still open in the card for it goes away.

Background processes stay in that group:

To start something that must outlive the skillie, hand it to macOS: open an app, a file or a URL.

While it runs

After it runs

ModeSuccess (exit 0)Failure (exit ≠ 0)
silentLast non-empty line, 2 sLast line, as an error
compactLast non-empty lineLast line, as an error
fullOutputAll of the output, scrollableAll of the output, as an error
inline (run with ↩)Last non-empty lineLast line, as an error
inline (read by itself)Last non-empty line beside its title in its row; in the menu barThe same: the exit status is ignored. Nothing printed: an empty spot in the row, the title in the menu bar

Printed nothing and exit 0: the card closes, nothing said. Printed nothing and failed: "“Title” failed (exit N)."

To an agent, run_skillie returns the whole output (its last 8,000 characters), or "Done." for none; a failure returns an error with the exit status and the last 2,000 characters.

Inline skillies

An inline skillie with no arguments is read without anyone running it:

Neither asks first, even with needsConfirmation, and the exit status is ignored: the line is whatever it printed last.

So keep an inline skillie quick (well under 10 s), read-only and cheap: it may run every time you open the launcher.

#!/bin/bash

# @skilli.schemaVersion 1
# @skilli.title Battery
# @skilli.mode inline
# @skilli.icon 🔋
# @skilli.refreshTime 5m

pmset -g batt | grep -Eo '[0-9]+%' | head -1

When the folder changes

skil.li keeps the list in memory and reads it again only when the skillies folder itself changed (its modification date): a file added, removed or renamed in it. Most editors save by replacing the file, which counts.

Edit this page on GitHub ↗