Skip to content

A Per-Monitor Hyprland Config in Omarchy

Omarchy’s default Hyprland configuration sets the gap between windows to 5 pixels (gaps_in) and the gap between windows and the monitor edges to 10 pixels (gaps_out).

That feels great on an external display, but on a 14” laptop panel every pixel is precious. I wanted smaller gaps on my laptop while keeping Omarchy’s defaults when I’m on a big monitor.

The second thing I wanted when docking: move my workspaces over to the external display.

I expected this to be doable with pure Hyprland config, but I could not figure it out. So I rely on a small script that runs on monitor attach/detach. If you know a better solution, please let me know.

1 - Install hyprland-monitor-attached

hyprland-monitor-attached is a small AUR package that calls a user script whenever a monitor is attached or detached.

yay -S hyprland-monitor-attached

2 - Create the script

This script runs every time a monitor connects or disconnects.

Create the script ~/bin/hypr-monitor-toggle:

#!/bin/bash

ext="DP-1"

for w in {1..10}; do
  if hyprctl monitors | grep -q "^Monitor $ext"; then
    hyprctl keyword "workspace $w, gapsout:10, gapsin:5"
    [ $w -ne 5 ] && hyprctl dispatch moveworkspacetomonitor $w $ext
  else
    hyprctl keyword "workspace $w, gapsout:3, gapsin:1"
  fi
done~/bin/hypr-monitor-toggle

Make it executable:

chmod +x ~/bin/hypr-monitor-toggle

3 - Run it on startup

The hyprland-monitor-attached daemon can be loaded on startup by adding it to autostart.conf. The command takes two arguments: a script to run on connect, and another script to run on disconnect. We use the same script for both.

exec-once = hyprland-monitor-attached ~/bin/hypr-monitor-toggle ~/bin/hypr-monitor-toggle
exec = ~/bin/hypr-monitor-toggle # Also executed when Hyprland reloads~/.config/hypr/autostart.conf

Notice the second line. The script also executes when the hyprland config is reloaded. Otherwise gaps can revert back to Omarchy’s default configuration after a reload.


Next Post
Remap That Useless Copilot Key