Repository navigation
Replies: 13 comments 12 replies
|
Thank you for putting this together. It is thoughful and helpful about learning concepts of the kernel I did not know about. I have a strong feeling this could be integrated in Omarchy once there is enough feedback from the community.
Unfortunately, it seems you artifact is not refered or attached to the tutorial. Is that something you could share please ? |
|
Great tutorial! I'm having some issues with the waybar being duplicated after the computer resumes from sleep/lockscreen. Toggling the bar off and on makes it go back to a single bar but it gets a bit annoying to have to do so often. Also waking up from sleep often ends up with the external monitor being in a weird resolution which fixes itself if the laptop is opened/closed again, however I've had these weird resolution bugs on the external monitor before using this script for managing the lids so probaly not worth considering an issue with this tutorial. |
|
Thanks for this, it's helpful. I'm running into an issue: when booting without the external monitor connected the laptop display is blank after login. I tried closing and re-opening the lid to trigger the lid open script but it didn't help. As a workaround I commented out changes to monitors.conf, and have been using the external-only command after startup (or just opening and closing the lid). The lid open and lid close actions are working the way they should. If someone can make a suggestion for troubleshooting this I'd appreciate it. As a side note, I wasn't sure in which file(s) and where to put: sleep 0.6 so I didn't do that step. |
|
Curious - does it handle multiple external monitors (i.e. more than one)? |
|
Thank you! I hit two snags that prevented me from completing this project, both due to my inexperience: Manual installation incomplete because of need to modify systemd bootloader files, which is not something I can do. Script installation incomplete due to "Source directory invalid" error when running install script. I'll keep revisiting this project as my knowledge improves. |
|
Thanks this was very helpful. I managed to set it up manually without much problems except for one major thing and I still can't figure it out. The exec and exec-once in the hyprland.conf for running the /etc/acpi/check-lid-on-startup.sh runs into an error when executing. the log: After some tests I've realized that it might happen because the exec 9>/run/lid-switch.lock and some other things in the hyper-utils.sh need to be executed as sudo. However the exec and exec-once commands execute it as user. I also tried the~/install-monitor-auto-switch.sh setup, but the problem persists UPDATE: I have found an ugly workaround (don't know if should be used) I used sudo visudo to give my user ability to use sudo only on /etc/acpi/check-lid-on-startup.sh without password. To do that use: Add line: Reboot system or relaunch hyprland Than refactor in hyprland.conf: To: |
|
Working like a charm, exactly what i needed today. The litle history i went to librairy to do some stuff, guess what forgot to uncomment my traditionnal way to disable the laptop screen. Thank you for this amazing scripts, hope will be set as default in omarchy. One thing went reboot while lib is closed, at startup the laptop screen remain disable event when the lib open and waybar is not launch. |
|
Hi all, Been working away at perfecting this, but wanted to wait for Omarchy 3.1.0 and its Hyprland changes before publishing them. I hope they they help make your life just a bit easier! |
|
I’d love to see this built into Omarchy by default — it feels natural and expected. Is anyone opposed to that? |
|
Thank you for this! |
|
Thank you!!! No issues! |
|
Thanks for creating this and making it available for others. Is there a reason to update both |
|
Hi everyone, I wanted to tell you about this software: This has solved my problem and it's working perfectly. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Automatic Monitor Switching Tutorial
Hyprland users often jump between laptop-only, docked, and dual-display setups. This tutorial packages everything needed to mirror my automatic lid-handling system without requiring access to my private
~/.dotfiles, just copy the snippets below into your own folder.What this gives you
journalctl -t lid-events, and handy manual aliases.The instructions assume:
sudoaccess.Step 0 – Prepare a working directory
Create a workspace that mirrors the layout expected by the installer (
acpi/andscripts/as siblings). Feel free to pick a different location; just stay consistent.Step 1 – Create the ACPI helper scripts
Copy each snippet into the indicated file. Adjust the configuration block in
hypr-utils.shso it matches your hardware (connector names, resolutions, scales, workspace layout).1.1
acpi/hypr-utils.sh1.2
acpi/lid-close.sh1.3
acpi/lid-open.sh1.4
acpi/check-lid-on-startup.shWhen you are finished, make the files executable:
Step 2 – Add the installer script
Create the installer at
~/monitor-auto-switch/scripts/install-monitor-auto-switch.sh:Step 3 – Install and enable
acpidsudo pacman -S --needed acpid sudo systemctl enable --now acpidAdjust the commands for your distribution if necessary.
Step 4 – Deploy the handlers
Run the installer from your workspace:
sudo ~/monitor-auto-switch/scripts/install-monitor-auto-switch.shThis command:
/etc/acpi/(backing up any modified versions)./etc/acpi/events/lid-openand/etc/acpi/events/lid-closewith the correct regex triggers./var/log/lid-events.logand sets its permissions to0666.acpidunless you pass--no-restart.exec-onceandexec) for/etc/acpi/check-lid-on-startup.shwhen a config is found./etc/acpi/check-lid-on-startup.shif Hyprland is active so the current session matches the real lid/monitor state.Useful flags:
-n/--dry-run– preview the actions.--src DIR,--dest DIR,--events-dir DIR– override source or destination paths.--no-restart– skip thesystemctl restart acpidstep.Step 5 – Verify the setup
Manual triggers
Watch
journalctl -t lid-events -n 20(or-f) for messages such asAuto-detected external monitor via sysfs: DP-3.Inspect Hyprland state
Confirm Hyprland hooks
Check
acpidStep 6 – Everyday usage
Optional aliases for quick toggles:
Live log view while testing hardware:
Whenever you change
~/monitor-auto-switch/acpi/hypr-utils.sh, rerun the installer so/etc/acpistays updated.How it works
acpidlistens forbutton/lidevents and executes/etc/acpi/lid-open.shor/etc/acpi/lid-close.sh./etc/acpi/hypr-utils.shbridges into the Hyprland session, auto-detects the active DP*/HDMI* connector, applies monitor layouts, moves workspaces, and logs vialogger -t lid-events./etc/acpi/check-lid-on-startup.shruns on Hyprland start/reload to keep layouts consistent even when booting with the lid closed.Troubleshooting
journalctl -t lid-eventsfor auto-detect messages. If the wrong connector is selected, updateEXTERNAL_MONITOR(e.g.,HDMI-A-1) inhypr-utils.shand redeploy.pgrep -x Hyprland). Without it, the scripts fall back to laptop-only.HandleLidSwitch=ignorein/etc/systemd/logind.confand consider adding the kernel parameterbutton.lid_init_state=open.flockguard—usually harmless. Wait a moment before retriggering.sudo journalctl -u acpidand confirm the event files exist under/etc/acpi/events/.Changelog
Tested on:
These scripts should work on other distributions with minor adjustments to package names, service management, or compositor behavior.
All reactions