Lidlock
Lock the laptop when lid is closed on Windows
Install / Use
/learn @linusyang92/LidlockREADME
LidLock
Lock Windows laptop when lid is closed
Introduction
LidLock is a simple app written in C for Windows to automatically lock the screen when the lid is closed. This resembles the same behavior as macOS, when one needs the laptop not to sleep but just to be locked when closing the lid.
The app also works with clamshell mode and external monitors. It will ignore locking if lid is open and external monitors are connected, and re-locks if the lid is closed and external monitors are disconnected.
Usage
LidLock is a single portable executable file. Simply double-click the executable and it silently runs as a daemon in the background without any windows, prompts or icons. It listens to relevant events and does not consume CPU when waiting.
If you want to stop LidLock, you can use Task Manager to stop the process, or run the following command in cmd:
taskkill /f /im lidlock.exe /t
To make it run at startup, create a shortcut of lidlock.exe and copy the shortcut to the startup folder (can be opened by executing shell:startup in Win+R).
Download and Compilation
The pre-compiled binaries can be found at Releases page.
The binary can be cross-compiled using MinGW-w64 as follows:
x86_64-w64-mingw32-gcc lidlock.c -o lidlock.exe -lole32 -lksguid -static -O2 -g0 -mwindows -Wall
For debugging, add a flag -DDEBUG during compiling and run the binary with a single argument which is the log file for tracking outputs:
lidlock.exe debug.log
Credits
This app is based on laplock by @dechamps and rewritten in C. The extra feature is the support of external monitors.
The license is the same as laplock (GPLv3):
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
