Screen Prank Locker: A macOS Prank App Built with Swift

Screen Prank Locker Screenshot

The Origin Story

There is an unwritten but strictly enforced rule in our team: if you leave your desk and forget to lock your laptop, you are buying the next round of beers. Usually, someone hijacks the abandoned machine and drops a generous-sounding post in the team chat: “Drinks are on me today!”. It is actually a fun tradition that conveniently enforces standard compliance and clean desk policies along the way.

At the last team event, it finally caught up with me, and boom, I ended up paying for drinks for seven colleagues. I paid up gladly, of course. Still, messing with someone else’s laptop is a bit cheeky. That screams for retaliation. Enter: SlashGordon’s grand revenge.

Screen Prank Locker is a macOS app that covers all screens with invisible overlays, ruthlessly intercepts every keyboard and mouse event, and punishes anyone who dares to touch the machine. Imagine a lock screen, but with a slightly sadistic personality.

How It Works

The app lurks silently in the background until you arm it. Once activated, it places transparent, full-screen windows over every connected monitor and swallows all input. The trap is set: the desktop looks completely normal and unlocked, a perfect honeypot for nosy coworkers. The victim sees the screen but can do absolutely nothing. Depending on the chosen protection mode, any attempt to interact triggers increasingly escalating and annoying reactions.

There are six different protection modes:

ModeWhat Happens
SilentNothing. The screen simply ignores the input. Maximum confusion.
FlashThe screen aggressively flashes white with every input attempt.
Flash & SoundStrobe light effect paired with a customizable macOS system sound.
Fart PrankPlays random fart noises (with a cooldown timer so the audio engine doesn’t crash). Classy. Embarrassing.
Custom MP3sFires off random MP3 files from a defined directory.
Webcam PrankSecretly snaps a photo of the intruder and plasters their confused face massively across the entire screen.

The webcam mode is my personal favorite. You can even set up a Telegram integration to push the culprit’s photo directly to your phone in real-time.

Webcam Prank mode capturing an intruder

The Escape Route

Naturally, the rightful owner needs a way back into the system. There are four ways out:

  • Typing a secret string completely blind (Default: unlock)
  • Touch ID (on supported Macs)
  • An emergency keyboard shortcut (Ctrl + Option + Cmd + Q)
  • A failsafe timeout that automatically kills the app after 30 minutes

The secret sequence is the most fun. You have to type the password without any visual feedback whatsoever, while the screen appears completely frozen. It feels exactly like defusing a bomb in a 90s action movie.

Under the Hood

The app is written in Swift 5.9 and targets macOS 13+. Under the hood, it uses the Accessibility API to intercept global keyboard and mouse events, the exact same mechanism macOS uses for accessibility features. This allows Screen Prank Locker to capture and block inputs even when the app doesn’t have active focus.

Multi-display support was significantly trickier than I initially thought. The app dynamically adapts if monitors are connected or disconnected during an active session, creating or destroying the overlay windows on the fly.

All configurations are stored as JSON under ~/.prank-locker/config.json. This makes it super easy to tweak everything, from activation hotkeys to the fart noise cooldown timers, without having to click through a graphical UI.

Building & Installation

The project uses Swift Package Manager and includes a handy Makefile with targets for all build steps:

make app    # Build the .app bundle
make dmg    # Create a distributable disk image
make pkg    # Create a macOS installer package

Since the app isn’t signed with an official Apple Developer certificate, macOS Gatekeeper will initially throw a fit and block the launch. You’ll need to strip the quarantine attribute after downloading:

xattr -cr /Applications/ScreenPrankLocker.app

After that, it launches normally from the Applications folder or via Spotlight.

Permissions

The app strictly requires Accessibility access to intercept inputs, this is non-negotiable. Camera access is obviously optional (only required for the Webcam Prank mode), just like Touch ID. On first launch, Screen Prank Locker requests all necessary permissions at once and redirects the user straight to System Settings if anything is missing.

Lessons Learned

While building this little side project, I learned a few things about macOS development that aren’t exactly on page one of the Apple documentation:

  • Strict Permissions: The Accessibility API is incredibly powerful, but the sandbox model is unforgiving. The app must be explicitly authorized in System Settings, and there is no way to force this programmatically in the background.
  • Global Events & Displays: Intercepting global events across multiple screens requires very precise management of screen coordinates and display states.
  • AVFoundation Timing: Camera capture itself is straightforward, but grabbing a sharp still frame at the exact right moment while the user is typing takes a bit of finesse with the timing.

Take It for a Spin

You can find the full source code on GitHub. Grab a release DMG, remove the quarantine flag, and prank your colleagues. Though you might want to subtly warn them about the fart noises beforehand.


Disclaimer: Screen Prank Locker is purely a hobby project. Use it responsibly, or don’t, I’m not your boss.