A small setup for Hyprland to disable a monitor (e.g. the laptop buildin screen) using hyprctl when a second screen is connected, and to re-enable the screen when all external displays have been disconnected.
- Create the file
switcher.shin your preferred directory (e.g./home/yourusername/scripts/). - Create the file
hypr-display-switcher.servicein/etc/systemd/user/. - Create the file
hyprland-display-switcher.rulesin/etc/udev/rules.d/. - (optional) Make sure that on every login the environment value
HYPR_BUILDIN_MONis set to your preferred settings. - Add
exec-once = /path/to/switcher.shto your hyprland config, so it get's set up when you log in. - Reload the systemd daemon with
systemctl daemon-reload. - Test the setup by (un)plugging a display to your computer.