Template data

The variables each capability gives a template. Stats refresh every 2 seconds, the time every second.

  • Every template gets theme. The rest need the matching capability.
  • settings holds the value of each setting the element offers.
  • At start-up, numbers are 0 and lists are empty until the first refresh.

theme

type ThemeStyle = {
  color: string;        // Tailwind colour name, e.g. "violet"
  opacity: number;      // 0–100, steps of 10
  lightDarkMode: "os" | "light" | "dark";
  font: string;         // applied automatically
  fontWeight: string;   // applied automatically
  textScale: number;    // 0.75–1.25, applied automatically
};

Sizes

Memory, GPU, disk and network sizes come in every unit (1024-based):

type ByteUnits = { bytes: number; kb: number; mb: number; gb: number; tb: number };

{{ memory.used.gb | round: 1 }} GB

The in_unit filter picks the unit for you. "auto" uses the largest unit where the value is at least 1; you can also give "kb", "mb", "gb" or "tb". The second value is the number of decimals (0–3).

{{ memory.used | in_unit: "auto", 1 }}              → 10.2 GB
{{ network.download | in_unit: "auto", 1 }}/s       → 4.2 MB/s
{{ memory.used | in_unit: "auto", settings.decimals }}

{% assign down = network.download | in_unit: "auto", 1 %}
{{ down.value }} <span class="opacity-60">{{ down.unit }}/s</span>

cpu

type CpuStats = {
  used_percent: number;
  frequency_mhz: number;
  core_count: number;
  thread_count: number;
  cores: { id: number; used_percent: number; frequency_mhz: number }[];
  history: number[];
};

memory

type MemoryStats = {
  total: ByteUnits;
  used: ByteUnits;
  available: ByteUnits;
  used_percent: number;
  free_percent: number;
  history: number[];
};

history holds up to 60 readings (2 minutes), oldest first. For a shorter range, take the newest: {% assign recent = cpu.history | slice: -15, 15 %}

disk

type DiskStats = {
  disks: {
    name: string;          // drive label, can be empty
    mount_point: string;   // e.g. "C:\"
    total: ByteUnits;
    used: ByteUnits;
    available: ByteUnits;
    used_percent: number;
    free_percent: number;
  }[];
};

network

type NetworkStats = {
  download: ByteUnits;   // per second
  upload: ByteUnits;     // per second
  total_received: ByteUnits;
  total_transmitted: ByteUnits;
  history: { download: number[]; upload: number[] }; // bytes per second
};

Network history is in bytes per second, not percent, so scale a graph by its peak. at_least keeps it working while the list is empty: {% assign peak = network.history.download | sort | last | at_least: 1 %}

gpu

type GpuStats = {
  name: string;               // empty when no GPU was found
  used_percent: number;       // the busiest engine, like Task Manager
  temperature: number | null; // °C, null when the driver doesn't report it
  memory: {                   // video memory
    total: ByteUnits;
    used: ByteUnits;
    available: ByteUnits;
    used_percent: number;
  };
  history: number[];
};

With more than one GPU, this is the one with the most video memory. Always handle a null temperature, for example by showing a dash.

dateTime

A string, formatted with the element's dateTime.format setting using Day.js tokens such as HH:mm or dddd D MMMM. To style two parts separately, use a format like HH:mm|dddd D MMMM and split: "|" it in the template.

dock

type Dock = {
  apps: { id: string; name: string; iconPath: string | null }[];
};

Show icons with object-contain, and handle null. To launch apps on click, see Hooks.