Custom Lid and External Monitor Behavior — Bash Script Solution #57
rafadorado
started this conversation in
Show and tell
Replies: 1 comment 6 replies
-
|
You can use Kanshi to manage the displays and add a lid trigger in the Hyprland configuration. It's a much simpler solution and achieves the same result. Still, great job! |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
First of all, thanks for Omarchy — after more than 10 years, I’m finally having fun configuring my system again.
I wanted to control the behavior when opening/closing the lid with an external monitor connected, and also detect when monitors are plugged or unplugged.
My Bash is pretty rusty, but with some AI help I got it working. There’s definitely more to improve, like handling workspaces across monitors, but this works for now.
🎯 Complete Steps for Reliable External Monitor Auto-Switch with Hyprland
✅ 1. System Requirements
acpidandudevavailable for lid/monitor event handling✅ 2. System Configurations
A. logind Config (Lid Behavior)
Edit:
Recommended:
Reload:
Outcome:
✅ 3.
hyprctlSignature for Root ScriptsIn your Hyprland startup config or
.profile:Purpose:
Allows root-triggered scripts to communicate with Hyprland safely.
✅ 4. Reliable External Monitor Detection Using
/sys/class/drmWe'll use:
/sys/class/drm/*/enabledMonitors listed here reflect real, kernel-level connection state.
✅ 5. Create Auto Layout Script
Save as:
Example Working Script:
Make executable:
✅ 6. Udev Rule for Monitor Hotplug
Content:
Reload:
✅ 7. ACPID Rule for Lid Events
Install ACPID if needed:
sudo pacman -S acpid sudo systemctl enable --now acpidCreate:
Content:
Restart ACPID:
🎯 8. Summary of Behavior
✅ Lid closed, no external monitor → suspend (logind handles this)
✅ Lid closed, external monitor → disables laptop screen
✅ Lid open, external monitor → both screens active
✅ Lid open, no external monitor → laptop screen only
🏁 9. Final Notes
$USERNAMEmust match your real user in the scripteDP-1) confirmed viahyprctl monitors/tmp/hypr_signatureon session startBeta Was this translation helpful? Give feedback.
All reactions