A macOS CLI program that listens for screen un/locks and notifies a cloud-based key/value store.
NOTE: the directions included in rest of the README assume you have cloned the repo and navigated to the program
directory.
Clone Instructions
git clone <url>
cd amiunlocked/program
You can install amiunlocked
by downloading the latest release or building the binary from source.
Navigate to the repo releases page and download the latest release wherever you prefer on your computer.
Building from source requires having the latest Xcode with Swift 5+ installed on your computer. In the program
directory, run the following commands:
swift package update
swift package generate-xcodeproj
swift build -c release
The program binary is located at ./.build/release/amiunlocked
. You can leave it there or copy it to another location on your computer.
amiunlocked
persists your computer's locked/unlocked state using a kvdb.io store called a "bucket". Using the provided scripts/setupDb.sh
script, take the following steps to create your own bucket:
- Open
scripts/setupDb.sh
- Generate two random strings for each of the following variables and enter them in the script:
secretKey
writeKey
- Save and run
scripts/setupDb.sh
- Copy/paste the output to a safe location. This information cannot be recovered if lost.
Running amiunlocked
requires two configuration settings: the url to your kvdb bucket (including the "key" of the key/value pair) and the writeKey
to give amiunlocked
write-access to the bucket. This configuration is kept in a config.json
file adjacent to the amiunlocked
binary. You can use config.json.example
as an example configuration file to get started.
-
Run the following command to create an empty
config.json
file:cp ./config.json.example /directory/container/program/config.json
-
Open
config.json
-
Fill in
url
with your kvdb bucket URL and the key you will store computer state at. For example, if your kvdb URL is "https://kvdb.io/abcdefg123456" and you are going to use the key "computer-state", the value forurl
would be "https://kvdb.io/abcdefg123456/computer-state". -
Fill in
writeKey
with the value generated for the Setup key/value store step -
Save and close the file
amiunlocked
can be configured using LaunchAgents. Take the following steps to set it up:
cd scripts
./createPlistFile.sh
# Provide the amiunlocked binary path to the script
./installPlistFile.sh
That's it. You can verify the process was installed as a LaunchAgent using the following command:
tail -f /tmp/com.amiunlocked.startup.stderr
# [2019-08-14 09:37:54.734 amiunlocked[3241:22125] Process: started