Units
Unit files define everything that wpm
needs to be able to manage a process.
Below is a non-trivial unit file for
komorebi which has been annotated to help
explain the various configuration options available.
Requires
is used to specify dependency relationships between different processes. In this example,komorebi
depends onwhkd
andkanata
, which means that if you attempt towpmctl start komorebi
,wpm
will check ifwhkd
andkanata
are both healthy and running before it attempts to startkomorebi
.Resources
is used to provide URLs to additional resources that the unit requires in order to run, such as configuration files. The key given to each URL here can be used to reference the cached location of the downloaded file on disk, for example, when passing a configuration file as an argument or an environment variable.Kind
is used to tellwpm
if this process continues running when launched (Simple
), runs and then exits (OneShot
), or runs and exits after forking a new process (Forking
).- Every unit has a complete set of lifecycle hooks available
(
ExecStartPre
,ExecStartPost
,ExecStop
,ExecStopPost
) to specify any preflight or cleanup tasks a process might require. Executable
can reference either an binary in the system$PATH
, a remote URL and checksum hash, or a Scoop package manifest. Remote binaries will be cached in a local store for future use, as will Scoop packages. The latter two approaches can be used to pin binary dependencies to exact versions (ie. enforcing service dependency consistency across a team)- Keys declared in
Resources
can be referenced as arguments using theResources.KEY
syntax inside of double curly braces. $USERPROFILE
will resolve toC:\Users\<YourUser>
when used inArguments
andEnvironment
Healthcheck
is used to tellwpm
how to validate the health of a process. This can be done by invoking a command until it returns with a successful exit code, or by checking the liveness of a process after a fixed period of time.
{
"$schema": "https://raw.githubusercontent.com/LGUG2Z/wpm/refs/heads/master/schema.unit.json",
"Unit": {
"Name": "komorebi",
"Description": "Tiling window management for Windows",
// [1]
"Requires": ["whkd", "kanata"]
},
// [2]
"Resources": {
"CONFIGURATION_FILE": "https://raw.githubusercontent.com/LGUG2Z/komorebi/refs/tags/v0.1.35/docs/komorebi.example.json"
},
"Service": {
// [3]
"Kind": "Simple",
// [4]
"ExecStartPre": [
{
"Executable": "komorebic.exe",
"Arguments": ["fetch-asc"]
}
],
"ExecStart": {
// [5]
"Executable": {
"Package": "komorebi",
"Version": "0.1.35",
"Manifest": "https://raw.githubusercontent.com/ScoopInstaller/Extras/8e21dc2cd902b865d153e64a078d97d3cd0593f7/bucket/komorebi.json",
"Target": "komorebi.exe"
},
"Arguments": [
"--config",
// [6]
"{{ Resources.CONFIGURATION_FILE }}"
],
"Environment": [
[
"KOMOREBI_CONFIG_HOME",
// [7]
"$USERPROFILE/.config/komorebi"
]
]
},
// [4]
"ExecStop": [
{
"Executable": "komorebic.exe",
"Arguments": ["stop"]
}
],
// [4]
"ExecStopPost": [
{
"Executable": "komorebic.exe",
"Arguments": ["restore-windows"]
}
],
// [8]
"Healthcheck": {
"Command": {
"Executable": "komorebic.exe",
"Arguments": ["state"],
"DelaySec": 1
}
},
"Restart": "Never"
}
}