Recovery from zero monitors (clamshell mode setup)

Just like you I’ve had some trouble setting up my laptop for seamless use between an external monitor and its native laptop screen.

Here’s a script that makes things kinda livable.

As you can see I’m also struggling to have a display lock BEFORE suspend (also pardon the old config syntax)

bindl = , switch:on:Lid Switch, exec, ~/.config/hypr/scripts/handle_lid_switch.sh
bindl = , switch:off:Lid Switch, exec, hyprctl keyword monitor “eDP-1, preferred, auto, 1”


#!/bin/bash

# Name of your laptop's built-in display (usually eDP-1)
LAPTOP_DISPLAY="eDP-1"

# Get total number of monitors
MONITOR_COUNT=$(hyprctl monitors -j | jq 'length')

# if count is greater than one
if [ "$MONITOR_COUNT" -gt 1 ]; then
        # External monitor is connected; disable laptop display
        sleep 2 & hyprctl keyword monitor "$LAPTOP_DISPLAY, disable"
else
        # No external display connected; lock screen and suspend
        # Replace this with your preferred locker (e.g., swaylock)
        #swaylock && systemctl suspend
        #swaylock -f -c 000000 & sleep 4 # && systemctl suspend
        pidof hyprlock || hyprlock




fi