RipCord

A script to put your Macbook to sleep

COMPUTERMAC

ADP

5/4/20251 min read

RipCord:

This was a fun little project. I put on my tinfoil hat, trying to think of a way a laptop (macbook) would automatically sleep/log-off if suddenly grabbed by a thief, cops, etc. I could see a few niche use cases for this admittedly unlikely scenario.

I figured a physical connection between user and laptop being broken would be one way to go about it, so I started trying to make a script that would make the laptop sleep if a USB memory stick (attached to the user via a USB extension cable) was removed.

With the help of chatgpt I was able to get something semi-working, but it was buggy.

Over to Reddit, running it past a few folks, and one user with legit skillz came up with a perfect script for the whole thing. He gave it the name RipCord and posted it on his GitHub.

Description:

About this script:
The intent of this project was to make a failsafe that would put a comptuer to sleep if someone were to steal the computer from someone sitting in public. This works by having a "key" drive that would be tethered to the user like a ripcord. If the computer were taken away forcefully, the USB drive would be removed and the computer will go to sleep.

This works by installing a script that will checks for the presense or absense of a USB drive specifially named RipCord. If at any point in time, the RipCord drive is removed, the computer will immediately go to sleep. The script runs automatically upon installation, and also on startup, ensuring that the safety protocol is constantly in effect.

The USB drive does not need to be present at all times, only if you believe your computer might be at risk. Removing the USB drive puts the computer to sleep, but only upon initial removal after being inserted. If you unlock the computer after the drive has been removed, it will not lock again until the drive has been reinserted and removed again.