This is a web app for macOS that serves an HTTP API to:
- check whether the screen is locked
- lock the screen
Install Python 3 (I used brew install python) and run the following from the
project root:
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txtTo start the app, run:
REMOTE_SCREEN_LOCKER_TOKEN=secret gunicorn remote_screen_locker.app:appTo run tests:
python -m unittestFor authentication, set the REMOTE_SCREEN_LOCKER_TOKEN environment variable
to the desired token when running the app. Provide an X-Token header with the
token for requests.
To get the screen status:
$ curl -H 'X-Token: secret' localhost:8000/screen
{"locked": false}To lock the screen:
$ curl -H 'X-Token: secret' -H 'Content-Type: application/json' -X PATCH -d '{"locked": true}' localhost:8000/screen
{"locked": true}