The
xrandr command can wake a suspended monitor by re-sending the active output configuration, but it requires the display server to be running and the port to remain electrically connected. To automate this on every boot or wake event, you should place the command in your session startup scripts rather than relying on complex power management daemons that may conflict with desktop environments. This approach ensures the screen initializes correctly after sleep cycles without needing third-party tools.
Understanding Monitor Power States and xrandr
When a Linux system enters a low-power state, such as suspend or idle timeout, the display manager often disables video outputs to save energy. The
xrandr utility interacts with the X Window System to configure these outputs. While
xrandr cannot physically send an electrical signal to wake a disconnected HDMI or DisplayPort cable (which would require EDID manipulation or hardware-level commands), it can re-enable the logical output within the display server.
This distinction is critical. If your monitor turns off due to a "no signal" state because the cable was unplugged,
xrandr will fail. However, if the monitor stays powered but goes into standby mode while remaining connected, re-running the
xrandr command that defines your resolution and position forces the graphics driver to re-establish the handshake with the display. This effectively wakes the panel.
For users managing multiple screens, ensuring consistency in how outputs are defined prevents the "ghost monitor" problem where one screen appears zoomed or misplaced. You can learn more about correcting display geometry issues in our guide on
Fix Display Appearing Zoomed With Multi-Monitor Setup Using xrandr.
Identifying Your Output Names
Before attempting to wake a monitor, you must know the exact identifier assigned by your system. These identifiers vary by distribution and hardware, commonly appearing as
HDMI-1,
DP-2,
VGA-1, or
eDP-1 for laptop internal screens.
Open a terminal and run the following command:
xrandr --query
Look for the section corresponding to your external monitor. A line starting with
HDMI-1 connected indicates the port is active. If it says
HDMI-1 disconnected, the system does not detect the monitor, and software commands will not wake it. You need to check your physical connections or refer to troubleshooting steps for hardware faults, such as those discussed in
Is my cable or iGPU at fault here?.
Once you have identified the correct name, note the current resolution and refresh rate settings. For example:
xrandr --output HDMI-1 --mode 1920x1080 --rate 60 --right-of eDP-1
Save this exact string. You will need it to restore the configuration later.
Manual Wake Procedure
If your monitor has entered standby mode and you need to wake it immediately without rebooting, you can use the saved configuration string. First, ensure the display server is responsive. If the entire interface is frozen, a simple
xrandr command will not work because the X server is unresponsive. In such cases, try switching to a TTY using
Ctrl+Alt+F3, then back to your graphical session with
Ctrl+Alt+F1 or
F2.
If the GUI is visible but the external monitor is black, run the command you saved earlier:
xrandr --output HDMI-1 --mode 1920x1080 --rate 60 --right-of eDP-1
This tells the X server to reconfigure the
HDMI-1 output. The graphics driver will then attempt to communicate with the monitor again. Most modern monitors interpret this renewed handshake as a wake signal and turn the backlight on.
If this fails, verify that the monitor itself is set to auto-detect input sources. Some monitors require manual switching between DP/HDMI inputs even when a signal is present. Check your monitor’s On-Screen Display (OSD) menu to ensure it is not locked to a specific source that might be ignoring the new signal.
Automating the Wake Process
To prevent the monitor from staying dark after a reboot or resume from sleep, you can automate the execution of the
xrandr command. The method depends on your desktop environment and display manager.
For most desktop environments like GNOME, KDE Plasma, or XFCE, you can add the command to your user’s autostart directory. Create a shell script named
wake-monitor.sh containing your
xrandr command:
#!/bin/bash
sleep 5
xrandr --output HDMI-1 --mode 1920x1080 --rate 60 --right-of eDP-1
Make the script executable:
chmod +x wake-monitor.sh
Then, add this script to your session's startup applications. In Ubuntu with GNOME, you can use the "Startup Applications" preference tool. Add a new entry pointing to the script. The
sleep 5 delay is crucial because the display server needs time to initialize before it can accept configuration changes. Running the command too early results in errors.
Alternatively, if you are using a window manager without a full desktop environment, you can add the command to your
~/.xinitrc or
~/.xprofile file. This ensures it runs every time the X server starts.
Troubleshooting Common Issues
If the monitor still does not wake after applying these steps, consider the following factors. First, check if your power management settings are forcing the GPU into a deep sleep state that cuts power to the PCIe or USB-C ports. Some laptops disable Thunderbolt or PCIe links during suspend, making software recovery impossible. Disabling "Deep Sleep" in BIOS/UEFI settings may help.
Second, verify that no other process is overriding your
xrandr settings. Tools like
arandr or display managers sometimes reset configurations upon login. Ensure your custom script runs after these tools have initialized.
Finally, if you experience screen glitches or artifacts after waking, the resolution or refresh rate might be unsupported by the monitor's current mode. You can diagnose this by listing available modes:
xrandr --output HDMI-1 --query
For more information on resolving visual artifacts and glitching displays, see our article on
Resolving Screen Glitch on Linux Distro: Using Particular Output Display Size.
Frequently Asked Questions
Can xrandr wake a monitor that is completely unplugged?
No,
xrandr operates at the software level within the X Window System. It cannot send electrical signals to a disconnected port. If the cable is unplugged, the OS detects a disconnection, and the monitor receives no signal regardless of software commands.
Why does my monitor stay black after reboot even with the script?
The script may be running before the display server is fully ready. Adding a
sleep duration (e.g.,
sleep 5) before the
xrandr command allows the graphics drivers to load completely, increasing the likelihood of a successful handshake.
How do I find the correct output name for my monitor?
Run
xrandr --query in the terminal. Look for lines that say "connected." The text immediately preceding "connected" is your output name, such as
HDMI-1 or
DP-2.
Will this method work on Wayland compositors?
Standard
xrandr commands are designed for X11. On Wayland, you should use
wayland-displays or your desktop environment's built-in display settings tool. Some compositors support
xrandr via compatibility layers, but it is not guaranteed to function identically.
What if the monitor goes back to sleep shortly after waking?
This is likely controlled by your power management daemon (like
systemd-logind or your DE's power settings). Adjust the "Screen Blank" or "Display Off" timeout settings in your system preferences to extend the duration before the monitor sleeps again.