Laptop lid in Fedora

Prevent systemd from Handling the Lid

By default, systemd's logind will suspend or do something with the lid event before Sway even gets a chance to act. You need to tell it to ignore the lid:

sudo mkdir -p /etc/systemd/logind.conf.d/
sudo nano /etc/systemd/logind.conf.d/clamshell.conf

Add these lines:

[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

Then restart logind:

sudo systemctl restart systemd-logind

Configure Sway to Handle the Lid Switch

Now let Sway react to the lid event directly. First, get your laptop screen name:

swaymsg -t get_outputs

Open your Sway config at ~/.config/sway/config and add the following (replace eDP-1 with your actual internal display name):

bindswitch --reload --locked lid:on output eDP-1 disable
bindswitch --reload --locked lid:off output eDP-1 enable

exec_always ~/.config/sway/clamshell.sh

Create the helper script ~/.config/sway/clamshell.sh:

#!/bin/bash
if grep -q open /proc/acpi/button/lid/*/state; then
    swaymsg output eDP-1 enable
else
    swaymsg output eDP-1 disable
fi

Make it executable:

chmod +x ~/.config/sway/clamshell.sh

Reload Sway

Press Super+Shift+C to reload the Sway config, or run:

swaymsg reload

Option 2: Use kanshi for Automatic Display Profiles

For a more robust solution, kanshi is a Wayland-native tool that automatically switches display profiles when outputs are connected or disconnected — similar to how Windows handles it:

sudo dnf install kanshi

Create ~/.config/kanshi/config:

profile docked {
    output eDP-1 disable
    output HDMI-A-1 enable mode 1920x1080 position 0,0
}

profile laptop {
    output eDP-1 enable
}

Then add to your Sway config:

exec_always kanshi

kanshi automatically detects which outputs are present and applies the correct profile, so when you close the lid and the internal screen is disabled, it switches seamlessly to the external monitor.