Skip to content

aos watch

Follow what changes on this machine, one JSON line per event

14 commands. Run aos watch --help for the same list from the binary, or see every group.

Wait for something to happen on this machine. With a condition (--match, --gone, --until, --exit, --for, --below) a watch exits 0 when it is met and 3 on --timeout, so an agent chains the next step with &&. Without one it prints one JSON line per event until interrupted. The first sample is a baseline, so --max=1 means the next change; watch clipboard hides the text unless --content is passed. Watches are blocking, so they are not MCP tools. For mail, Teams, WhatsApp or calendar events use apl. See waiting for things.

Wait for a battery level or charging state, or print a JSON line for each power change

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch battery [--below=<pct>] [--above=<pct>] [--until=charging|discharging|full] [--interval=<5s>] [--timeout=<dur>] [--json]
flag values meaning
--below <pct> Optional
--above <pct> Optional
--until charging, discharging, full Optional
--interval <5s> Optional. default 5s
--timeout <dur> Optional
--json Optional
Terminal window
aos watch battery --below=20 && echo time to save work # exit 0 once the charge is under 20%
aos watch battery --until=full --timeout=3h # exit 3 if it is not full in 3 hours
aos watch battery --until=discharging # exit 0 when the charger is pulled
aos watch battery # a JSON line for plugged, unplugged, full and each % change

Report when any app starts or stops using the camera

needs a display darwin · windows only

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch camera [--until=busy|free] [--interval=<1s>] [--timeout=<duration>] [--json]
flag values meaning
--until busy, free Optional
--interval <1s> Optional. default 1s
--timeout <duration> Optional
--json Optional
Terminal window
aos watch camera
aos watch camera --until=busy --timeout=10m
aos watch camera --until=free && echo 'call is over, start the build'
aos watch camera --json
# with --until: exit 0 when the state is reached (at once if it already is), 3 on --timeout

Print a JSON line whenever the clipboard text changes

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch clipboard [--interval=<500ms>] [--max=<n>] [--content]
flag values meaning
--interval <500ms> Optional. default 500ms
--max <n> Optional
--content Optional
Terminal window
aos watch clipboard
aos watch clipboard --max=1 --content

Report when a USB drive, audio device or Bluetooth device is connected or removed

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch device [--kind=volume|audio|bluetooth[,...]] [--until=added|removed] [--interval=<2s>] [--timeout=<duration>] [--json]
flag values meaning
--kind volume, audio, bluetooth[,... Optional. comma-separated
--until added, removed Optional
--interval <2s> Optional. default 2s
--timeout <duration> Optional
--json Optional
Terminal window
aos watch device
aos watch device --kind=volume --until=added --timeout=2m
aos watch device --kind=audio,bluetooth --json
aos watch device --kind=bluetooth --until=removed && echo 'headphones dropped, pause the music'
# with --until: exit 0 on the first matching event, 3 on --timeout

Wait for a monitor to be plugged in or removed, or print a JSON line for each

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch display [--until=added|removed|<count>] [--interval=<2s>] [--timeout=<dur>] [--json]
flag values meaning
--until added, removed, <count> Optional
--interval <2s> Optional. default 2s
--timeout <dur> Optional
--json Optional
Terminal window
aos watch display --until=added && aos window move Chrome --monitor=2 # exit 0 when a monitor appears
aos watch display --until=removed --timeout=10m # exit 3 if none is unplugged in 10m
aos watch display --until=2 # exit 0 once exactly 2 monitors are attached
aos watch display # a JSON line per monitor added or removed

Print a JSON line whenever a file or directory entry changes

needs a display

Under WSL / SSH: runs inside WSL (where aos was started). How the host works

Terminal window
aos watch file <path> [--interval=<500ms>] [--max=<n>] [--recursive]
flag values meaning
<path> Required positional argument
--interval <500ms> Optional. default 500ms
--max <n> Optional
--recursive Optional
Terminal window
aos watch file ~/Downloads
aos watch file ./notes.md --max=1
aos watch file ./src --recursive --interval=1s

Exit 0 once the person has been idle for a while, or as soon as they are active again

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch idle (--for=<duration> | --active) [--interval=<1s>] [--timeout=<duration>] [--json]
flag values meaning
--for <duration> One of these is required
--active One of these is required
--interval <1s> Optional. default 1s
--timeout <duration> Optional
--json Optional
Terminal window
aos watch idle --for=10m && echo "away from the desk"
aos watch idle --active --timeout=1h # block until the next key press or mouse move
aos watch idle --for=5m --json
# idle time is input idle: macOS HIDIdleTime, Windows GetLastInputInfo, Linux xprintidle (X11 only)
# exit 0 when met, 3 on --timeout, 1 when this machine cannot report idle time

Print a JSON line when the screen locks or unlocks and when the machine sleeps or wakes

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch lock [--until=locked|unlocked|sleep|wake] [--interval=<1s>] [--timeout=<duration>] [--max=<n>]
flag values meaning
--until locked, unlocked, sleep, wake Optional
--interval <1s> Optional. default 1s
--timeout <duration> Optional
--max <n> Optional
Terminal window
aos watch lock
aos watch lock --until=unlocked --timeout=2h && echo "the person is back"
aos watch lock --until=locked
aos watch lock --until=wake --timeout=8h
# lock: macOS CGSession, Windows WTS session state. sleep: seen as a gap in the poll clock, so sleep and wake are reported together on resume (sleep carries slept_ms)
# --until exits 0 when that state is reached (at once if already locked/unlocked), 3 on --timeout

Report when any app starts or stops using the microphone

needs a display darwin · windows only

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch mic [--until=busy|free] [--interval=<1s>] [--timeout=<duration>] [--json]
flag values meaning
--until busy, free Optional
--interval <1s> Optional. default 1s
--timeout <duration> Optional
--json Optional
Terminal window
aos watch mic
aos watch mic --until=free --timeout=1h
aos watch mic --until=busy && echo 'someone is on a call'
aos watch mic --json
# with --until: exit 0 when the state is reached (at once if it already is), 3 on --timeout

Print a JSON line when the machine goes online or offline or changes Wi-Fi network

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch network [--until=online|offline] [--timeout=<duration>] [--max=<n>] [--interval=<5s>]
flag values meaning
--until online, offline Optional
--timeout <duration> Optional
--max <n> Optional
--interval <5s> Optional. default 5s
Terminal window
aos watch network
aos watch network --until=online --timeout=10m && aos exec -- git push
aos watch network --until=offline
# --until: exit 0 when that state is reached (at once if already there), 3 on --timeout

Wait for one process to end or appear, or print a JSON line for each start and stop

needs a display

Under WSL / SSH: runs inside WSL (where aos was started). How the host works

Terminal window
aos watch process --name=<name> | --pid=<n> [--exit | --start] [--interval=<1s>] [--timeout=<dur>] [--json]
flag values meaning
--name <name> One of these is required
--pid <n> One of these is required
--exit Optional
--start Optional
--interval <1s> Optional. default 1s
--timeout <dur> Optional
--json Optional
Terminal window
aos watch process --name=ffmpeg --exit && echo render done # exit 0 when ffmpeg ends
aos watch process --pid=4821 --exit --timeout=30m # exit 3 if it is still running after 30m
aos watch process --name=Xcode --start # exit 0 when Xcode appears
aos watch process --name=node # a JSON line per start and stop

Print a JSON line with the new text whenever a browser tab’s page changes

needs a display darwin · windows only

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch tab (--id=<tab id> | --url=<substring> | --title=<substring>) [--app=<name>] [--match=<text> | --gone=<text>] [--near=<anchor text>] [--exact] [--reload=<duration>] [--interval=<1s>] [--timeout=<duration>] [--max=<n>] [--focus]
flag values meaning
--id <tab id> One of these is required
--url <substring> One of these is required
--title <substring> One of these is required
--app <name> Optional
--match <text> Optional
--gone <text> Optional
--near <anchor text> Optional
--exact Optional
--reload <duration> Optional
--interval <1s> Optional. default 1s
--timeout <duration> Optional
--max <n> Optional
--focus Optional
Terminal window
aos watch tab --id=chrome:1658108662:1658109078
aos watch tab --url=web.whatsapp.com --match="Build finished" --timeout=5m
aos watch tab --url=example.com/slots --reload=30s --match="Book now" && aos tab click --url=example.com/slots --find="Book now"
aos watch tab --url=example.com/order --reload=1m --gone="Out of stock" --timeout=2h
aos watch tab --url=example.com/item --near="Price" --match="$" --reload=5m
# with --match / --gone: exit 0 when the condition is met, 3 on --timeout or when the tab closes

Poll a URL over plain HTTP and report when its text changes, appears or goes away

needs a display

Under WSL / SSH: runs inside WSL (where aos was started). How the host works

Terminal window
aos watch url <url> [--every=<1m>] [--match=<text> | --gone=<text>] [--exact] [--timeout=<duration>] [--max=<n>]
flag values meaning
<url> Required positional argument
--every <1m> Optional. default 1m
--match <text> Optional
--gone <text> Optional
--exact Optional
--timeout <duration> Optional
--max <n> Optional
Terminal window
aos watch url https://example.com/status
aos watch url https://example.com/release --every=5m --match="v2.0" --timeout=12h && aos open https://example.com/release
aos watch url https://shop.example.com/item --every=10m --gone="Out of stock"
# with --match / --gone: exit 0 when the condition is met, 3 on --timeout
# pages that need a login or JavaScript: use `aos watch tab`

Print a JSON line whenever the focused window changes, or wait for text to appear or vanish in a window

needs a display

Under WSL / SSH: runs on the Windows host (the machine with the screen). How the host works

Terminal window
aos watch window [--interval=<500ms>] [--max=<n>] | (--app=<name> | --title=<substring>) (--match=<text> | --gone=<text>) [--exact] [--new] [--interval=<2s>] [--timeout=<duration>] [--source=auto|accessibility|ocr] [--json]
flag values meaning
--interval <500ms> Optional. default 500ms
--max <n> Optional
--app <name> One of these is required
--title <substring> One of these is required
--match <text> One of these is required
--gone <text> One of these is required
--exact Optional
--new Optional
--timeout <duration> Optional
--source auto, accessibility, ocr Optional
--json Optional
Terminal window
aos watch window
aos watch window --max=1
aos watch window --app=Teams --match="Muthu" --timeout=1h && echo "message arrived"
aos watch window --app=Slack --match=deploy --new --json
aos watch window --app=Notes --gone="Syncing" --timeout=2m
# text mode reads the window like `window text`; exit 0 when met, 3 on --timeout; never raises or moves the window