How To Call It
System is a global table: call its functions with a dot (System.<method>(...)), not a colon. Requires Macro Handler 1.0.62 or later.
Sets an audio stream to the supported step nearest the requested percentage and verifies the actual volume index; returns false if it cannot be verified.
Documented for app version 1.0.64Updated:
System is a global table: call its functions with a dot (System.<method>(...)), not a colon. Requires Macro Handler 1.0.62 or later.
In system flow, design steps as observe first and act second when the API can affect device state.
stream: music, ring, notification, alarm, system. percent: finite Lua number from 0–100; decimals are accepted. The percentage maps to Android’s minimum/maximum index range. Numeric strings, NaN, infinity and out-of-range values return false without side effects.
Root is not required; Android audio policies apply. Fixed-volume devices, Do Not Disturb access and OS restrictions may reject an operation. The API does not request or elevate permission. Use it on the macro runtime thread; it does not perform work on the main UI thread.
Read the actual level with System.getVolume. Choose Volume level in the System block’s Android Actions mode or use Automation.action("set_volume", {stream="music", percent=30}); that higher-level path treats false as an error.
The snippet below is a starter pattern that can be applied directly in runtime flow.
local changed = System.setVolume("music", 30)
print("Volume verified", changed)From foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
local changed = System.setVolume("music", 30)
print("Volume verified", changed)local stepOk = true
local changed = System.setVolume("music", 30)
print("Volume verified", changed)
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
local changed = System.setVolume("music", 30)
print("Volume verified", changed)
end)
if not ok then
print("API step failed: System.setVolume: " .. tostring(err))
requestStop()
end-- In system flow, design steps as observe first and act second when the API can affect device state.
local function run_setvolume_step()
local changed = System.setVolume("music", 30)
print("Volume verified", changed)
end
local ok, err = pcall(run_setvolume_step)
if not ok then
toast("Step failed")
print(err)
endlocal state = System.getVolume("music")
if state ~= nil and not state.fixed then
assert(System.setVolume("music", 30), "Volume could not be verified")
end