### Install via Shell Script
Source: https://docs.steambrew.app/users/getting-started/installation
Execute the automatic installation script for Linux distributions using a pre-built binary.
```bash
curl -fsSL "https://steambrew.app/install.sh" | bash
```
--------------------------------
### Perform GET requests with Lua HTTP
Source: https://docs.steambrew.app/plugins/lua/http
Demonstrates basic GET requests and how to include custom headers and timeouts.
```lua
local http = require("http")
local res, err = http.get("https://api.example.com/users")
if not res then
print("GET failed:", err)
else
print("status:", res.status)
print("body length:", #res.body)
end
-- With custom headers and timeout
local res, err = http.get("https://api.example.com/data", {
headers = { ["Accept"] = "application/json" },
timeout = 5
})
```
--------------------------------
### Get Steam Installation Path
Source: https://docs.steambrew.app/plugins/lua/millennium
Retrieve the full directory path where Steam is installed.
```lua
local path = millennium.steam_path()
```
--------------------------------
### ProgressBar Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/ProgressBar
Demonstrates how to import and implement a basic indeterminate ProgressBar component.
```tsx
import { ProgressBar } from 'millennium';
;
```
--------------------------------
### Check string prefix
Source: https://docs.steambrew.app/plugins/lua/utils
Determines if a string starts with the specified prefix.
```lua
local result = utils.startswith("hello", "hel")
```
--------------------------------
### Implementing Focusable Component
Source: https://docs.steambrew.app/plugins/ts/components/Focusable
Basic usage example showing how to import and wrap content with the Focusable component.
```tsx
import { Focusable } from 'millennium';
console.log('activated')} className="MyRow">
Row content
;
```
--------------------------------
### Initialize Millennium Module
Source: https://docs.steambrew.app/plugins/lua/millennium
Basic setup to require the Millennium module and access its functions.
```lua
local millennium = require("millennium")
-- Ex. use Millennium module to get Steam path
millennium.steam_path()
```
--------------------------------
### Verify JavaScript Setup
Source: https://docs.steambrew.app/themes/advanced/scripting
A basic console log to confirm that your JavaScript module is correctly loaded and executing.
```javascript
console.log('Hello, World!');
```
--------------------------------
### Clone and Build Plugin Template
Source: https://docs.steambrew.app/plugins/introduction/quick-start
Use these commands to initialize a new plugin project from the official template and install necessary dependencies.
```sh
# clone plugin template
$ git clone "https://github.com/SteamClientHomebrew/PluginTemplate"
$ cd PluginTemplate
# install dependencies and build
$ bun install
$ bun run build
```
--------------------------------
### Retrieve Millennium Version
Source: https://docs.steambrew.app/plugins/lua/millennium
Get the current version string of the Millennium installation.
```lua
local version = millennium.version()
```
--------------------------------
### Configure skin.json for CSS and JS injection
Source: https://docs.steambrew.app/themes/intermediate/user
Example configuration showing how to define CSS and JS targets with regex selectors for window matching.
```json
{
"TargetCss": {
"affects": [".*"],
"src": "some.css"
},
"TargetJs": {
"affects": ["^Steam$", "https:\/\/steamcommunity.com\/.*"],
"src": "some.js"
}
}
```
--------------------------------
### Performing HTTP requests
Source: https://docs.steambrew.app/plugins/lua/http
Demonstrates making a simple GET request and a configured POST request with headers and custom timeout settings.
```lua
local http = require("http")
-- Simple GET
local res, err = http.request("https://api.example.com/data")
if not res then
print("request failed:", err)
else
print("status:", res.status)
print("body:", res.body)
end
-- Custom POST with headers and timeout
local res, err = http.request("https://api.example.com/submit", {
method = "POST",
data = '{"key":"value"}',
headers = {
["Content-Type"] = "application/json",
["Authorization"] = "Bearer token123"
},
timeout = 10,
verify_ssl = true
})
```
--------------------------------
### millennium.steam_path()
Source: https://docs.steambrew.app/plugins/lua/millennium
Retrieves the file system path to the Steam installation directory.
```APIDOC
## millennium.steam_path()
### Description
Returns the full path to the Steam installation directory.
### Returns
- **path** (string) - The full path to the Steam installation directory.
```
--------------------------------
### Implement Marquee component
Source: https://docs.steambrew.app/plugins/ts/components/Marquee
Basic usage example showing how to import and wrap content with the Marquee component.
```tsx
import { Marquee } from 'millennium';
;
```
--------------------------------
### SteamSpinner Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/SteamSpinner
Demonstrates how to import and conditionally render the SteamSpinner component.
```tsx
import { SteamSpinner } from 'millennium';
if (!hasLoaded) return ;
```
--------------------------------
### ButtonItem Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/ButtonItem
Demonstrates how to import and implement the ButtonItem component within a React application.
```tsx
import { ButtonItem } from 'millennium';
resetSettings()} />;
```
--------------------------------
### Custom Patch Entry Example
Source: https://docs.steambrew.app/themes/intermediate/custom-structure
A single patch entry targeting windows with the FullModalOverlay classname.
```json
{
"MatchRegexString": ".FullModalOverlay",
"TargetCss": "libraryroot.custom.css",
"TargetJs": "libraryroot.custom.js"
}
```
--------------------------------
### Get table keys
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves all keys from a table as an array.
```lua
local keys = utils.keys({a = 1, b = 2})
```
--------------------------------
### Implement Panel Layout
Source: https://docs.steambrew.app/plugins/ts/components/Panel
Example of nesting PanelSectionRow and ButtonItem within a PanelSection.
```tsx
import { PanelSection, PanelSectionRow, ButtonItem } from 'millennium';
{}} />
;
```
--------------------------------
### Get table values
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves all values from a table as an array.
```lua
local values = utils.values({a = 1, b = 2})
```
--------------------------------
### Get file size
Source: https://docs.steambrew.app/plugins/lua/fs
Retrieves the size of a regular file in bytes.
```lua
local fs = require("fs")
local size, err = fs.file_size("b.txt")
if size then
print("b.txt size:", size)
else
print("file_size failed:", err)
end
```
--------------------------------
### Dropdown Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/Dropdown
Demonstrates how to implement a Dropdown within a Field component using the millennium library.
```tsx
import { Dropdown, Field } from 'millennium';
const options = [
{ data: 'stable', label: 'Stable' },
{ data: 'beta', label: 'Beta' },
];
opt.data === channel)} onChange={(e) => setChannel(e.data)} strDefaultLabel={options.find((opt) => opt.data === channel)?.label} />
;
```
--------------------------------
### Basic TextField Usage
Source: https://docs.steambrew.app/plugins/ts/components/TextField
Example of importing and implementing a basic TextField component with controlled value state.
```tsx
import { TextField } from 'millennium';
setValue(e.target.value)} />;
```
--------------------------------
### Get environment variable
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves the value of a specified environment variable.
```lua
local path = utils.getenv("PATH")
```
--------------------------------
### Find Steam path on Windows and Linux
Source: https://docs.steambrew.app/users/guides/finding-steam
Use these commands to retrieve the Steam installation directory on Windows via PowerShell or locate the default directory on Linux.
```powershell
(gp "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam").InstallPath
```
```bash
~/.steam/steam
```
--------------------------------
### Optimize CSS Selectors
Source: https://docs.steambrew.app/themes/advanced/performance
Examples of refactoring descendant and attribute selectors to improve performance and specificity.
```css
.main .container .row => .container .row-wrap .row
```
```css
.card-container .card => .card.card-info
```
```css
.container .row => .row.row.row
```
```css
[attr=value]
```
```css
[attr*=val]
```
--------------------------------
### Get parent path
Source: https://docs.steambrew.app/plugins/lua/fs
Returns the directory path containing the specified file or directory.
```lua
local fs = require("fs")
print(fs.parent_path("/tmp/archive.tar.gz")) -- /tmp
```
--------------------------------
### Get current path in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Returns the current working directory of the process.
```lua
local fs = require("fs")
print("cwd:", fs.current_path())
```
--------------------------------
### http.get
Source: https://docs.steambrew.app/plugins/lua/http
A convenience wrapper for making GET requests. It accepts a URL and optional request configuration.
```APIDOC
## http.get(url, options)
### Description
Performs a GET request to the specified URL. Defaults to the GET method.
### Parameters
- **url** (string) - Required - The URL to request.
- **options** (HTTPOptions) - Optional - Configuration options for the request.
### Returns
- **response** (HTTPResponse | nil) - The response object or nil on failure.
- **error** (string | nil) - The error message if the request failed.
```
--------------------------------
### Get backend path
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves the backend path from the MILLENNIUM_PLUGIN_SECRET_BACKEND_ABSOLUTE environment variable.
```lua
local path = utils.get_backend_path()
```
--------------------------------
### ScrollPanel Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/Scroll
Basic implementation of a ScrollPanel component wrapping content.
```tsx
import { ScrollPanel } from 'millennium';
Long content...
;
```
--------------------------------
### ToggleField Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/ToggleField
Basic implementation of the ToggleField component within a React application.
```tsx
import { ToggleField } from 'millennium';
;
```
--------------------------------
### DialogCheckbox Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/DialogCheckbox
Basic implementation of the DialogCheckbox component within a React application.
```tsx
import { DialogCheckbox } from 'millennium';
;
```
--------------------------------
### Backend Configuration Listener and Management
Source: https://docs.steambrew.app/plugins/advanced/config
Demonstrates registering a change listener and performing manual get/set operations on configuration keys.
```lua
-- register listener
millennium.config.on_change(function(key, value)
logger:info("Config changed: " .. key .. " = " .. tostring(value))
end)
-- get config key
local greeting = millennium.config.get("greeting")
-- fire a config change
millennium.config.set("greeting", "Hello from Lua!")
```
--------------------------------
### HTML Structure for Specificity Examples
Source: https://docs.steambrew.app/themes/basics/selectors
The base HTML structure used to demonstrate how different CSS selectors target elements.
```html
Text
```
--------------------------------
### Retrieve Millennium version on Linux
Source: https://docs.steambrew.app/users/guides/finding-millennium-version
Provides distribution-specific commands to check the installed package version for Arch Linux and NixOS.
```bash
# Arch Linux
pacman -Q millennium
# NixOS
nix eval --raw '.#nixpkgs.legacyPackages.x86_64-linux.millennium.version'
# Other Distributions
# There is no current documentation on how find Millennium's version from the terminal.
# You'll need run 'steam' directly from the terminal and
# monitor the logs, or check Millennium's version within Millennium Settings.
```
--------------------------------
### Create directories recursively
Source: https://docs.steambrew.app/plugins/lua/fs
Creates a directory and any necessary parent directories.
```lua
local fs = require("fs")
local ok, err = fs.create_directories("tmp/project/sub")
if not ok then
print("create_directories failed:", err)
end
```
--------------------------------
### DialogControlsSection Usage
Source: https://docs.steambrew.app/plugins/ts/components/Dialog
Example of implementing a control section within a dialog using Field and Toggle components.
```tsx
import { DialogControlsSection, DialogButton, Field, Toggle } from 'millennium';
Save
;
```
--------------------------------
### fs.create_directories(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Creates a directory and all necessary parent directories.
```APIDOC
## fs.create_directories(path)
### Description
Creates a directory and any missing parent directories.
### Parameters
- **path** (string) - Required - The directory path to create.
### Returns
- **Boolean/Nil** - true on success, or nil and an error message on failure.
```
--------------------------------
### cjson.decode_max_depth()
Source: https://docs.steambrew.app/plugins/lua/cjson
Gets or sets the maximum nesting depth for the JSON decoder.
```APIDOC
## cjson.decode_max_depth()
### Abstract
Get or set maximum decoding nesting depth.
### Parameters
- **depth** (integer) - Optional - Maximum allowed nesting depth for decoding
### Returns
Current maximum depth (integer).
### Example
```lua
cjson.decode_max_depth(10)
```
```
--------------------------------
### Retrieve Millennium version on Windows
Source: https://docs.steambrew.app/users/guides/finding-millennium-version
Uses PowerShell to query the registry for the Steam installation path and extract the file version from the millennium.dll metadata.
```powershell
(gi "$(gp 'HKLM:\SOFTWARE\Wow6432Node\Valve\Steam' | % InstallPath)\millennium\lib\millennium.dll").VersionInfo.FileVersion
```
--------------------------------
### cjson.encode_max_depth()
Source: https://docs.steambrew.app/plugins/lua/cjson
Gets or sets the maximum nesting depth for the JSON encoder.
```APIDOC
## cjson.encode_max_depth()
### Abstract
Get or set maximum encoding nesting depth.
### Parameters
- **depth** (integer) - Optional - Maximum allowed nesting depth (1..2^31-1)
### Returns
Current maximum depth (integer).
### Example
```lua
cjson.encode_max_depth(5)
```
```
--------------------------------
### Get absolute path in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Converts a relative path into its absolute form.
```lua
local fs = require("fs")
print(fs.absolute("./docs"))
```
--------------------------------
### Basic Logging Pattern
Source: https://docs.steambrew.app/plugins/lua/logger
Demonstrates standard usage of info, warn, and error methods.
```lua
local logger = require("logger")
logger:info("Starting task")
logger:warn("Low disk space")
logger:error("Task failed")
```
--------------------------------
### Configure Nix Overlay
Source: https://docs.steambrew.app/users/getting-started/installation
Import the Millennium overlay into your nixpkgs configuration.
```nix
nixpkgs.overlays = [ inputs.millennium.overlays.default ];
```
--------------------------------
### openQuickAccess Usage
Source: https://docs.steambrew.app/plugins/ts/Millennium
Opens the Millennium Quick Access Menu (QAM) to the home page, a specific theme, or a plugin.
```typescript
Millennium.openQuickAccess();
Millennium.openQuickAccess({ theme: 'themeName' });
Millennium.openQuickAccess({ plugin: 'pluginName' });
```
--------------------------------
### Get current time
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieve the current Unix timestamp in various precisions.
```lua
local timestamp = utils.time()
```
```lua
local timestamp = utils.time_ms()
```
```lua
local timestamp = utils.time_micro()
```
--------------------------------
### Importing the regex module
Source: https://docs.steambrew.app/plugins/lua/regex
Load the regex module to access its utility functions.
```lua
local regex = require("regex")
```
--------------------------------
### Initialize Datetime Plugin
Source: https://docs.steambrew.app/plugins/lua/datetime
Load the datetime module to access its functions.
```lua
local datetime = require("datetime")
```
--------------------------------
### Initialize Logger
Source: https://docs.steambrew.app/plugins/lua/logger
Load the logger module into your plugin script.
```lua
local logger = require("logger")
```
--------------------------------
### Importing the HTTP module
Source: https://docs.steambrew.app/plugins/lua/http
Initializes the HTTP module for use in a Lua script.
```lua
local http = require("http")
```
--------------------------------
### Create a single directory
Source: https://docs.steambrew.app/plugins/lua/fs
Creates a directory at the specified path without creating parent directories.
```lua
local fs = require("fs")
local ok, err = fs.create_directory("/tmp/mydir")
if not ok then
print("failed:", err)
end
```
--------------------------------
### SliderField Usage Example
Source: https://docs.steambrew.app/plugins/ts/components/SliderField
Basic implementation of the SliderField component within a React application.
```tsx
import { SliderField } from 'millennium';
;
```
--------------------------------
### Configure Nix Flake Input
Source: https://docs.steambrew.app/users/getting-started/installation
Add the Millennium repository as an input in your flake.nix file.
```nix
millennium.url = "github:SteamClientHomebrew/Millennium?dir=packages/nix";
```
--------------------------------
### Implement Context Menu Usage
Source: https://docs.steambrew.app/plugins/ts/components/Menu
Demonstrates how to trigger a context menu using the showContextMenu function with Menu and MenuItem components.
```tsx
import { Menu, MenuItem, MenuSeparator, showContextMenu } from 'millennium';
showContextMenu(
,
parentElement,
);
```
--------------------------------
### fs.create_directory(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Creates a single directory.
```APIDOC
## fs.create_directory(path)
### Description
Creates a single directory. Note that this does not create parent directories.
### Parameters
- **path** (string) - Required - The directory path to create.
### Returns
- **Boolean/Nil** - true on success, or nil and an error message on failure.
```
--------------------------------
### Initialize utils module
Source: https://docs.steambrew.app/plugins/lua/utils
Load the utils module to access its exported functions.
```lua
local utils = require("utils")
-- Ex. use utils module to sleep
utils.sleep(1000)
```
--------------------------------
### Get canonical path in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Resolves a path to its canonical form, including symlink resolution.
```lua
local fs = require("fs")
local p, err = fs.canonical("some/symlink")
if not p then print("canonical failed:", err) end
```
--------------------------------
### Get Current Time in Seconds
Source: https://docs.steambrew.app/plugins/lua/datetime
Retrieve the current time as seconds since the Unix epoch.
```lua
local datetime = require("datetime")
local s = datetime.unix()
print("seconds since epoch:", s)
```
--------------------------------
### Launch Steam in developer mode on Windows
Source: https://docs.steambrew.app/developers/devtools
Add the -dev argument to the target path of a Steam shortcut.
```text
"C:\Program Files (x86)\Steam\steam.exe" -dev
```
--------------------------------
### Get Current Time in Milliseconds
Source: https://docs.steambrew.app/plugins/lua/datetime
Retrieve the current time as milliseconds since the Unix epoch.
```lua
local datetime = require("datetime")
local ms = datetime.now()
print("milliseconds since epoch:", ms)
```
--------------------------------
### millennium.ready()
Source: https://docs.steambrew.app/plugins/lua/millennium
Signals to Millennium that the plugin's Lua backend has finished loading. Must be called within 10 seconds of initialization.
```APIDOC
## millennium.ready()
### Description
Used to let Millennium know when your plugin's Lua backend is ready. It should be called within 1 second of loading for optimal user experience.
### Returns
- **success** (boolean) - True if the ready message was sent successfully.
```
--------------------------------
### Configure Nix System Packages
Source: https://docs.steambrew.app/users/getting-started/installation
Add the Millennium-patched Steam package to your system packages list if not using the Steam module.
```nix
environment.systemPackages = [
# Your other packages...
inputs.millennium.packages."${pkgs.system}".millennium-steam
];
```
--------------------------------
### utils.startswith
Source: https://docs.steambrew.app/plugins/lua/utils
Checks if a string begins with a specific prefix.
```APIDOC
## utils.startswith(str, prefix)
### Description
Check if a string starts with a prefix.
### Parameters
- **str** (string) - String to check
- **prefix** (string) - Prefix to look for
### Returns
- True if string starts with prefix (boolean).
### Usage
```lua
local result = utils.startswith("hello", "hel")
```
```
--------------------------------
### Get last write time in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Retrieves the last modification time of a file as a Unix timestamp.
```lua
local fs = require("fs")
local t, err = fs.last_write_time("b.txt")
if t then
print("last write:", t)
else
print("last_write_time failed:", err)
end
```
--------------------------------
### Launch Steam with Developer Mode
Source: https://docs.steambrew.app/users/getting-started/troubleshooting
Commands to launch Steam in developer mode to generate logs for troubleshooting.
```powershell
& "$((gp 'HKLM:\SOFTWARE\WOW6432Node\Valve\Steam').InstallPath)\steam.exe" -dev
```
```bash
steam -dev
```
--------------------------------
### Millennium.openQuickAccess
Source: https://docs.steambrew.app/plugins/ts/Millennium
Opens the Millennium Quick Access Menu (QAM).
```APIDOC
## Millennium.openQuickAccess(target?)
### Description
Opens the Millennium Quick Access Menu (QAM) to the home page, a specific theme, or a specific plugin.
### Parameters
- **target** ({ plugin: string } | { theme: string }) - Optional - The target to open the QAM to. If omitted, opens the home page.
```
--------------------------------
### Signal Plugin Readiness
Source: https://docs.steambrew.app/plugins/lua/millennium
Notify Millennium that the plugin backend has loaded. This must be called within 1 second to avoid crash detection.
```lua
local millennium = require("millennium")
local function on_load()
-- let millennium know your plugin has loaded.
millennium.ready()
end
return {
-- ... other functions ...
on_load = on_load
}
```
--------------------------------
### IconsModule Usage
Source: https://docs.steambrew.app/plugins/ts/components/IconsModule
How to import and use icons and the Spinner component from the millennium package.
```APIDOC
## IconsModule Usage
### Description
The `IconsModule` provides a collection of SVG icon components. Icons can be used as React components, supporting standard SVG attributes like `className`.
### Usage Example
```tsx
import { IconsModule, Spinner } from 'millennium';
;
;
;
```
### Debugging
To inspect the available icons in the SharedJSContext console, use:
```typescript
MILLENNIUM_API.IconsModule;
```
```
--------------------------------
### Implement ControlsList in JSX
Source: https://docs.steambrew.app/plugins/ts/components/ControlsList
Example usage of the ControlsList component to group DialogButton elements with right alignment.
```tsx
import { ControlsList, DialogButton } from 'millennium';
Cancel
OK
;
```
--------------------------------
### Import ChromeDevToolsProtocol
Source: https://docs.steambrew.app/plugins/ts/ChromeDevToolsProtocol
Import the protocol client from the millennium package.
```typescript
import { ChromeDevToolsProtocol } from 'millennium';
```
--------------------------------
### Launch Steam in developer mode on Linux
Source: https://docs.steambrew.app/developers/devtools
Execute the steam command with the -dev flag in a terminal.
```bash
steam -dev
```
--------------------------------
### Get relative path in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Calculates a path relative to a specified base directory or the current working directory.
```lua
local fs = require("fs")
print(fs.relative("/tmp/project/file.txt", "/tmp"))
```
--------------------------------
### showContextMenu
Source: https://docs.steambrew.app/plugins/ts/components/Menu
Displays a context menu at a specified location. Returns a ContextMenuInstance to control the visibility of the menu.
```APIDOC
## showContextMenu
### Description
Displays a context menu containing the provided children components. Returns an instance that allows for manual hiding or showing of the menu.
### Signature
`showContextMenu(children: ReactNode, parent?: EventTarget, options?: ContextMenuPositionOptions) => ContextMenuInstance`
### Parameters
- **children** (ReactNode) - The menu content, typically composed of Menu, MenuGroup, MenuItem, and MenuSeparator components.
- **parent** (EventTarget) - Optional parent element for positioning.
- **options** (ContextMenuPositionOptions) - Optional configuration for menu positioning.
### Returns
- **ContextMenuInstance** - An object with `Hide()` and `Show()` methods to manage the menu state.
```
--------------------------------
### Define a Dropdown Configuration
Source: https://docs.steambrew.app/themes/intermediate/user
Creates a configurable dropdown menu in the theme settings. Values other than 'yes' and 'no' are automatically rendered as dropdowns.
```json
"Conditions": {
"A ComboBox Item": {
"description": "A simple combo box",
"tab": "Theme",
"default": "Dark",
"values": {
"Dark": {
"TargetCss": {
"affects": ["^Steam$", "^Steam Big Picture Mode$"],
"src": "dark.css"
}
},
"Amoled": {
"TargetCss": {
"affects": [".*"],
"src": "amoled.css"
}
},
"Nord": {
"TargetCss": {
"affects": [".*"],
"src": "nord.css"
}
}
}
}
}
```
--------------------------------
### Optimize Animations and Transitions
Source: https://docs.steambrew.app/themes/advanced/performance
Techniques to hint browser optimization and trigger GPU acceleration for smoother animations.
```css
will-change: property;
```
```css
transform: translateZ(0)
```
```css
will-change: transform
```
--------------------------------
### Retrieve filesystem space information
Source: https://docs.steambrew.app/plugins/lua/fs
Returns a table containing capacity, free, and available space for the volume, or nil and an error message on failure.
```lua
local fs = require("fs")
local info, err = fs.space_info(".")
if info then
print("capacity:", info.capacity)
else
print("space_info failed:", err)
end
```
--------------------------------
### http.request(url, options)
Source: https://docs.steambrew.app/plugins/lua/http
Makes a generic HTTP request with full configuration options.
```APIDOC
## http.request(url, options)
### Description
Make a generic HTTP request with full configuration. This is the most flexible entry point and can be used to implement any method or custom behavior by providing an options table.
### Parameters
- **url** (string) - Required - URL to request
- **options** (HTTPOptions) - Optional - Request configuration options
### Returns
- **response** (HTTPResponse | nil) - Response object, or nil on failure
- **error** (string | nil) - Error message if request failed
```
--------------------------------
### Logging with Context
Source: https://docs.steambrew.app/plugins/lua/logger
Include relevant identifiers in log messages to make them more actionable.
```lua
local logger = require("logger")
local user_id = 12345
logger:info("User " .. user_id .. " logged in")
logger:error("Payment failed for user " .. user_id .. " : code " .. err_code)
```
--------------------------------
### Check filesystem path existence
Source: https://docs.steambrew.app/plugins/lua/fs
Use the exists function to verify if a file or directory exists at the specified path.
```lua
local fs = require("fs")
print(fs.exists("config.json"))
```
```lua
local fs = require("fs")
print(fs.exists("/etc/passwd"))
```
--------------------------------
### Error Handling and Propagation
Source: https://docs.steambrew.app/plugins/lua/logger
Use logging to create an audit trail when operations fail.
```lua
local logger = require("logger")
local http = require("http")
local res, err = http.get("https://api.example.com/data")
if not res then
logger:error("HTTP request failed: " .. tostring(err))
return nil, err
end
if res.status ~= 200 then
logger:warn("Unexpected status: " .. tostring(res.status))
end
```
--------------------------------
### Displaying a Confirm Modal
Source: https://docs.steambrew.app/plugins/ts/components/Modal
Demonstrates how to trigger a confirmation dialog using showModal and ConfirmModal.
```tsx
import { showModal, ConfirmModal } from 'millennium';
showModal( doThing()} />);
```
--------------------------------
### Join path components
Source: https://docs.steambrew.app/plugins/lua/fs
Combines multiple path strings into a single path using the native system separator.
```lua
local fs = require("fs")
print(fs.join("tmp", "data", "file.txt"))
```
--------------------------------
### Configure Root Colors in skin.json
Source: https://docs.steambrew.app/themes/intermediate/colors
Define the path to the CSS file containing color variables. Ensure the file contains only the :root block.
```json
{
"RootColors": "path/to/colors.css"
}
```
--------------------------------
### Compare Semantic Versions
Source: https://docs.steambrew.app/plugins/lua/millennium
Compare two version strings to conditionally execute logic based on the Millennium version.
```lua
-- Check if a feature introduced in Millennium 2.30.0 is available
if millennium.cmp_version(millennium.version(), "2.30.0") >= 0 then
-- Feature is available
print("Feature available")
else
-- Feature is not available
print("Feature not available")
end
```
--------------------------------
### Carousel Basic Usage
Source: https://docs.steambrew.app/plugins/ts/components/Carousel
Demonstrates how to import and implement the Carousel component with required properties.
```tsx
import { Carousel } from 'millennium';
id} fnItemRenderer={(id) => {id}
} />;
```
--------------------------------
### Create a new cjson instance
Source: https://docs.steambrew.app/plugins/lua/cjson
Instantiates a new cjson object to maintain independent configuration settings without affecting the global state.
```lua
local custom = cjson.new()
custom.encode_max_depth(5)
local s = custom.encode({ value = 1 })
```
--------------------------------
### fs.join(...)
Source: https://docs.steambrew.app/plugins/lua/fs
Joins multiple path components into a single path string using the native separator.
```APIDOC
## fs.join(...)
### Description
Join multiple path components using the native separator and return the resulting path string.
### Parameters
- **...** (string) - Required - Multiple string path components.
### Returns
- **string** - Joined path string.
```
--------------------------------
### ModalRoot
Source: https://docs.steambrew.app/plugins/ts/components/Modal
The base component for creating fully custom modals.
```APIDOC
## ModalRoot
### Description
Wraps custom content to create a modal structure.
### Props
- **children** (ReactNode) - Optional - Content inside the modal.
- **onCancel** (function) - Optional - Callback when cancelled.
- **onOK** (function) - Optional - Callback when OK is pressed.
- **className** (string) - Optional - CSS class for the container.
- **bAllowFullSize** (boolean) - Optional - Allows the modal to take full size.
```
--------------------------------
### Check if path is empty
Source: https://docs.steambrew.app/plugins/lua/fs
Verifies if a file is zero bytes or a directory contains no entries.
```lua
local fs = require("fs")
print(fs.is_empty("empty.txt"))
```
--------------------------------
### AddWindowCreateHook Usage
Source: https://docs.steambrew.app/plugins/ts/Millennium
Registers a callback to fire whenever a new Steam window spawns. This is a legacy API and should be avoided in favor of the configuration API.
```typescript
function windowCreated(context: any) {
// window create event.
console.log(context);
}
export default definePlugin(() => {
Millennium.AddWindowCreateHook(windowCreated);
// ... the rest
});
```
--------------------------------
### send(method, params?, sessionId?)
Source: https://docs.steambrew.app/plugins/ts/ChromeDevToolsProtocol
Send a CDP command and await the result.
```APIDOC
## send(method, params?, sessionId?)
### Description
Send a CDP command and await the result. Returns a promise resolving to the command's result, or rejecting on error.
### Parameters
- **method** (string) - Required - A CDP command name (e.g., 'DOM.getDocument').
- **params** (object) - Optional - Parameters per the CDP method's schema.
- **sessionId** (string) - Optional - Target a specific CDP session.
### Example
```typescript
const { root } = await ChromeDevToolsProtocol.send('DOM.getDocument');
await ChromeDevToolsProtocol.send('Page.navigate', { url: 'https://example.com' });
```
```
--------------------------------
### Check if path is a file
Source: https://docs.steambrew.app/plugins/lua/fs
Verify if a given path points to an existing regular file.
```lua
local fs = require("fs")
print(fs.is_file("README.md"))
```
--------------------------------
### Clone Theme Template
Source: https://docs.steambrew.app/themes/introduction/quick-start
Commands to navigate to the Steam skins directory and clone the template repository for both Windows and Linux environments.
```powershell
# Note: this is a PowerShell script
# cd into Steam skins folder
cd "$(gp 'HKLM:\SOFTWARE\Wow6432Node\Valve\Steam' | % InstallPath)\steamui\skins"
# clone the repository
git clone "https://github.com/SteamClientHomebrew/ThemeTemplate"
cd ThemeTemplate
# Optional: Open VSCode
code .
```
```bash
# cd into Steam skins folder
cd ~/.steam/steam/steamui/skins
# clone the repository
git clone "https://github.com/SteamClientHomebrew/ThemeTemplate"
cd ThemeTemplate
# Optional: Open VSCode
code .
```
--------------------------------
### utils.exec
Source: https://docs.steambrew.app/plugins/lua/utils
Executes a shell command and captures the output and exit status.
```APIDOC
## utils.exec(cmd)
### Description
Execute a shell command and capture output.
### Parameters
- **cmd** (string) - Required - Command to execute
### Returns
- (string|nil, integer|string) - Command output or nil on error, and exit status or error message.
### Usage
```lua
local output, status = utils.exec("echo hello")
```
```
--------------------------------
### Configure frontend globals mapping
Source: https://docs.steambrew.app/plugins/structure/config
Maps import specifiers to global references, which are rewritten at compile time.
```toml
"react" = "window.SOME_FAKE_REACT"
```
--------------------------------
### fs.list(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Lists entries in a directory non-recursively.
```APIDOC
## fs.list(path)
### Description
List entries in a directory (non-recursive). Returns an array of entry tables.
### Parameters
- **path** (string) - Required - Directory to list
### Returns
- **table/nil** - Array of entry tables on success, or nil on error.
- **string/nil** - Error message if an error occurred.
### Entry Fields
- **name** (string)
- **path** (string)
- **is_directory** (boolean)
- **is_file** (boolean)
- **is_symlink** (boolean)
- **size** (number) - Present for regular files when available
```
--------------------------------
### Configure NixOS Steam Module
Source: https://docs.steambrew.app/users/getting-started/installation
Set the Steam package to the Millennium-patched version within the NixOS Steam module.
```nix
programs.steam = {
enable = true;
package = pkgs.millennium-steam;
};
```
--------------------------------
### fs.copy(from, to, throw_error)
Source: https://docs.steambrew.app/plugins/lua/fs
Copies a file or directory (non-recursive) from a source path to a destination path.
```APIDOC
## fs.copy(from, to, throw_error)
### Description
Copies a file or directory (non-recursive). Overwrites existing destination by default.
### Parameters
- **from** (string) - Source path
- **to** (string) - Destination path
- **throw_error** (boolean) - If truthy, raises a Lua error on failure. Otherwise returns nil, err.
### Returns
- **success** (boolean) - true on success; on failure either raises (if throw_error) or returns nil, error_message.
```
--------------------------------
### Implement FocusRing usage
Source: https://docs.steambrew.app/plugins/ts/components/FocusRing
Wraps focusable content with the FocusRing component to enable focus outline rendering.
```tsx
import { FocusRing } from 'millennium';
Focusable content
;
```
--------------------------------
### Check if path is a directory
Source: https://docs.steambrew.app/plugins/lua/fs
Verify if a given path points to an existing directory.
```lua
local fs = require("fs")
print(fs.is_directory("/tmp"))
```
--------------------------------
### Handle filesystem errors in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Check for nil return values when performing filesystem operations to handle failures gracefully.
```lua
local fs = require("fs")
local ok, err = fs.create_directory("/protected/dir")
if not ok then
print("failed:", err)
end
```
--------------------------------
### Basic Field Usage
Source: https://docs.steambrew.app/plugins/ts/components/Field
Demonstrates how to wrap a control, such as a Toggle, within a Field component.
```tsx
import { Field, Toggle } from 'millennium';
;
```
--------------------------------
### http.post
Source: https://docs.steambrew.app/plugins/lua/http
A convenience wrapper for making POST requests, allowing for a request body and custom options.
```APIDOC
## http.post(url, data, options)
### Description
Performs a POST request to the specified URL with an optional request body and configuration options.
### Parameters
- **url** (string) - Required - The URL to request.
- **data** (string) - Optional - The request body to send.
- **options** (HTTPOptions) - Optional - Configuration options for the request.
### Returns
- **response** (HTTPResponse | nil) - The response object or nil on failure.
- **error** (string | nil) - The error message if the request failed.
```
--------------------------------
### utils.write_file(path, content)
Source: https://docs.steambrew.app/plugins/lua/utils
Writes content to a file, overwriting any existing data.
```APIDOC
## utils.write_file(path, content)
### Description
Write content to a file. This overwrites existing files.
### Parameters
- **path** (string) - Required - File path
- **content** (string) - Required - Content to write
### Returns
- **success** (boolean) - True if successful or nil on error.
- **err** (string) - Error message if failed.
```
--------------------------------
### fs.space_info(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Retrieves filesystem space information for the volume containing the specified path.
```APIDOC
## fs.space_info(path)
### Description
Return filesystem space information for the volume containing `path`.
### Parameters
- **path** (string) - Required - Path on target volume
### Returns
- **table** - On success a table { capacity = number, free = number, available = number }, or nil, error_message on failure.
```
--------------------------------
### utils.get_backend_path()
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves the backend path from the environment variable.
```APIDOC
## utils.get_backend_path()
### Description
Get the backend path from MILLENNIUM_PLUGIN_SECRET_BACKEND_ABSOLUTE variable.
### Returns
- **path** (string) - The backend path or nil if not set.
```
--------------------------------
### Execute Millennium commands on Windows
Source: https://docs.steambrew.app/users/guides/millennium-protocol
Run commands using PowerShell or Command Prompt.
```powershell
Start-Process "steam://your_command"
```
```cmd
start "steam://your_command"
```
--------------------------------
### Execute shell command
Source: https://docs.steambrew.app/plugins/lua/utils
Runs a shell command and captures its output and exit status.
```lua
local output, status = utils.exec("echo hello")
```
--------------------------------
### Append to file
Source: https://docs.steambrew.app/plugins/lua/utils
Appends content to an existing file. Returns true on success or nil with an error message on failure.
```lua
local success, err = utils.append_file("/path/to/file.txt", "world")
```
--------------------------------
### Conditional Debug Logging
Source: https://docs.steambrew.app/plugins/lua/logger
Gate verbose logging behind configuration settings.
```lua
local logger = require("logger")
local verbose = plugin_config.verbose
if verbose then
logger:info("Verbose mode enabled - detailed startup logs follow")
end
```
--------------------------------
### Copy a file or directory
Source: https://docs.steambrew.app/plugins/lua/fs
Copies a single file or directory without recursion. Overwrites the destination by default.
```lua
local fs = require("fs")
local ok, err = fs.copy("a.txt", "b.txt", false)
if not ok then
print("copy failed:", err)
end
```
--------------------------------
### List directory entries
Source: https://docs.steambrew.app/plugins/lua/fs
Lists entries in a directory non-recursively. Returns an array of entry tables or nil and an error message on failure.
```lua
local fs = require("fs")
local entries, err = fs.list(".")
if not entries then
print("list failed:", err)
else
for i, e in ipairs(entries) do
print(i, e.name, e.is_directory and "(dir)" or tostring(e.size))
end
end
```
--------------------------------
### ConfirmModal
Source: https://docs.steambrew.app/plugins/ts/components/Modal
A pre-built modal component for OK/Cancel dialogs, extending ModalRoot functionality.
```APIDOC
## ConfirmModal
### Description
A component for standard confirmation dialogs. Supports custom titles, descriptions, and button text.
### Props
- **strTitle** (ReactNode) - Optional - The title of the modal.
- **strDescription** (ReactNode) - Optional - The body text of the modal.
- **strOKButtonText** (ReactNode) - Optional - Text for the OK button.
- **strCancelButtonText** (ReactNode) - Optional - Text for the Cancel button.
- **strMiddleButtonText** (ReactNode) - Optional - Text for an optional middle button.
- **bAlertDialog** (boolean) - Optional - If true, only shows the OK button.
- **onMiddleButton** (function) - Optional - Callback for the middle button.
```
--------------------------------
### Write to file
Source: https://docs.steambrew.app/plugins/lua/utils
Overwrites a file with the provided content. Returns true on success or nil with an error message on failure.
```lua
local success, err = utils.write_file("/path/to/file.txt", "hello")
```
--------------------------------
### Create a timestamp from components
Source: https://docs.steambrew.app/plugins/lua/datetime
Constructs a timestamp in milliseconds from a table of date components using local timezone semantics.
```lua
local datetime = require("datetime")
local ts = datetime.create({
year = 2025,
month = 1,
day = 15,
hour = 12,
minute = 0,
second = 0
})
print("ms:", ts)
print("formatted:", datetime.format(ts))
```
--------------------------------
### Define a Checkbox Configuration
Source: https://docs.steambrew.app/themes/intermediate/user
Creates a boolean checkbox in the theme settings. If the values contain only 'yes' and 'no', the configuration is rendered as a checkbox.
```json
"Conditions": {
"A Boolean Checkbox": {
"default": "yes",
"description": "A simple boolean checkbox",
"tab": "General",
"values": {
"no": {
"TargetCss": {
"affects": [".*"], "src": "no.css"
}
},
"yes": {
"TargetCss": {
"affects": [".*"], "src": "yes.css"
}
}
}
}
}
```
--------------------------------
### Log Informational Messages
Source: https://docs.steambrew.app/plugins/lua/logger
Use for routine runtime information and progress updates.
```lua
local logger = require("logger")
logger:info("Plugin initialized successfully")
logger:info("Processed " .. count .. " items")
```
--------------------------------
### utils.keys
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves all keys from a table.
```APIDOC
## utils.keys(tbl)
### Description
Get all keys from a table.
### Parameters
- **tbl** (table) - Table to extract keys from
### Returns
- An array of keys.
### Usage
```lua
local keys = utils.keys({a = 1, b = 2})
```
```
--------------------------------
### Execute Millennium commands on Linux
Source: https://docs.steambrew.app/users/guides/millennium-protocol
Run commands directly from the terminal using the steam protocol.
```bash
steam steam://your_command
```
--------------------------------
### Import and use icons
Source: https://docs.steambrew.app/plugins/ts/components/IconsModule
Import icons and the Spinner component from the millennium package to render them as JSX elements.
```tsx
import { IconsModule, Spinner } from 'millennium';
;
;
;
```
--------------------------------
### Perform mathematical operations
Source: https://docs.steambrew.app/plugins/lua/utils
Common math utilities for rounding, clamping, sign checking, and linear interpolation.
```lua
local result = utils.round(3.7) -- returns 4
```
```lua
local result = utils.clamp(15, 0, 10) -- returns 10
```
```lua
local result = utils.sign(-5) -- returns -1
```
```lua
local result = utils.lerp(0, 100, 0.5) -- returns 50
```
--------------------------------
### Create a new safe cjson instance
Source: https://docs.steambrew.app/plugins/lua/cjson
Initializes a new safe cjson instance, allowing for independent configuration of encoder settings like max depth.
```lua
local safe_json = cjson.safe.new()
safe_json.encode_max_depth(5)
local json, err = safe_json.encode({ data = "value" })
if not json then print("Error:", err) end
```
--------------------------------
### datetime.create
Source: https://docs.steambrew.app/plugins/lua/datetime
Creates a timestamp in milliseconds since the epoch from a table of date components using local timezone semantics.
```APIDOC
## datetime.create(t)
### Description
Creates a timestamp (milliseconds since epoch) from a table of components. Missing fields default to zero-like values as per std::tm semantics.
### Parameters
- **t** (table) - Required - Table with fields `year`, `month`, `day`, `hour`, `minute`, `second`
### Returns
- **Integer** - Milliseconds since epoch representing the supplied date/time in the local timezone.
```
--------------------------------
### fs.canonical(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Returns the canonical path, resolving any symlinks.
```APIDOC
## fs.canonical(path)
### Description
Return the canonical (resolved symlinks) path.
### Parameters
- **path** (string) - Required - Input path.
### Returns
- Canonical path string, or `nil, error_message` on failure.
```
--------------------------------
### Specificity with Attribute and :where() Selectors
Source: https://docs.steambrew.app/themes/basics/selectors
Illustrates how ID selectors, attribute selectors, and the :where() pseudo-class differ in specificity weight.
```css
#myContent h1 {
color: green;
}
[id="myContent"] h1 {
color: yellow;
}
:where(#myContent) h1 {
color: blue;
}
```
--------------------------------
### Set current path in Lua
Source: https://docs.steambrew.app/plugins/lua/fs
Updates the current working directory for the process.
```lua
local fs = require("fs")
local ok, err = fs.set_current_path("/tmp")
if not ok then
print("set_current_path failed:", err)
end
```
--------------------------------
### Basic JSON encoding and decoding
Source: https://docs.steambrew.app/plugins/lua/cjson
Perform basic serialization and deserialization of Lua tables and JSON strings.
```lua
local cjson = require("json")
local json = cjson.encode({ name = "Alice", online = true })
local obj = cjson.decode('{"name":"Alice","online":true}')
```
--------------------------------
### Access frontend instances with macros
Source: https://docs.steambrew.app/plugins/advanced/hooking
Use the # macro in replace strings to reference exported frontend objects.
```typescript
#{{self}}?.hookedSettingsIcon?.SteamButton()
```
--------------------------------
### fs.exists
Source: https://docs.steambrew.app/plugins/lua/fs
Checks whether a filesystem path exists.
```APIDOC
## fs.exists(path)
### Description
Check whether a filesystem path exists.
### Parameters
- **path** (string) - Required - Path to check
### Returns
- **Boolean** - true if the path exists, otherwise false.
```
--------------------------------
### Send CDP commands
Source: https://docs.steambrew.app/plugins/ts/ChromeDevToolsProtocol
Execute CDP commands and await the returned promise.
```typescript
const { root } = await ChromeDevToolsProtocol.send('DOM.getDocument');
await ChromeDevToolsProtocol.send('Page.navigate', { url: 'https://example.com' });
```
--------------------------------
### Toggle Component Usage
Source: https://docs.steambrew.app/plugins/ts/components/Toggle
Demonstrates how to implement the Toggle component within a Field for labeled input.
```tsx
import { Field, Toggle } from 'millennium';
;
```
--------------------------------
### fs.set_current_path(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Sets the current working directory for the process.
```APIDOC
## fs.set_current_path(path)
### Description
Set the current working directory for the process.
### Parameters
- **path** (string) - Required - Directory to set as CWD.
### Returns
- `true` on success or `nil, error_message` on failure.
```
--------------------------------
### datetime.to_unix(ms)
Source: https://docs.steambrew.app/plugins/lua/datetime
Converts milliseconds-since-epoch to seconds.
```APIDOC
## datetime.to_unix(ms)
### Description
Convert milliseconds-since-epoch to seconds (integer division).
### Parameters
- **ms** (integer) - Required - Milliseconds since epoch
### Returns
- **Integer**: seconds since epoch (ms // 1000).
```
--------------------------------
### utils.getenv
Source: https://docs.steambrew.app/plugins/lua/utils
Retrieves the value of a specified environment variable.
```APIDOC
## utils.getenv(name)
### Description
Get an environment variable.
### Parameters
- **name** (string) - Required - Environment variable name
### Returns
- (string|nil) - The environment variable value or nil if not found.
### Usage
```lua
local path = utils.getenv("PATH")
```
```
--------------------------------
### fs.absolute(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Returns the absolute form of a path.
```APIDOC
## fs.absolute(path)
### Description
Return the absolute form of a path.
### Parameters
- **path** (string) - Required - Input path.
### Returns
- Absolute path string, or `nil, error_message` on failure.
```
--------------------------------
### fs.is_empty(path)
Source: https://docs.steambrew.app/plugins/lua/fs
Checks if a file or directory is empty.
```APIDOC
## fs.is_empty(path)
### Description
Returns whether the path is empty. For files, this means zero bytes; for directories, this means it contains no entries.
### Parameters
- **path** (string) - Required - The path to check.
### Returns
- **Boolean** - true if empty, otherwise false.
```
--------------------------------
### Define on method signature
Source: https://docs.steambrew.app/plugins/ts/ChromeDevToolsProtocol
Signature for subscribing to a CDP event.
```typescript
on(event, listener): () => void
```