In Windows, Windows Key + P changes how an attached monitor is attached. I primarilly used it to swap between mirrored and extended views.

Is there a similar hotkey in Ubuntu 14.04?

To clarify, I'm often in the situation where my built-in display is blank after being plugged into HDMI and suspendend. I think it just needs to be told to switch to a different display mode. I can't do this with a command, as I can't see what I'm typing.

I've googled, and my google fu doesn't appear to be working well

  • Now there is a Super+P at 20.04 LTS! Hurray! Feb 18 '21 at 11:31

If you don't find a simple built-in shortcut, you can do what I do on Xubuntu and use xrandr to switch the display output. All of this might seem like a pain in the ass, but I've found it to be rock solid reliable over the years (especially compared to relying on display auto-switching).

$ sudo apt-get install xrandr

So on my setup, this command switches to mirrored output:

xrandr --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off \
--output DP1 --off --output eDP1 --mode 1920x1080 --pos 2040x0 --rotate normal \
--same-as HDMI1 --output VGA1 --off

And this one switches to extended desktop:

xrandr --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off \
--output DP1 --off --output eDP1 --mode 1920x1080 --pos 2040x0 --rotate normal \
--output VGA1 --off

Obviously, these commands are too long to be typing in, so I save them to scripts called display_TV_mirror.sh and display_TV_extend.sh, and then I bind a shortcut key to each script. In regular Ubuntu, I think you can set the shortcuts in System Settings -> Keyboard -> Shortcuts. I use to separate scripts with two separate shortcut keys, but you could easily combine them into one switch with some toggle logic.

Note: To find out the exact command you want to use for xrandr, it is probably easier to use arandr at first, which is basically a gui interface to xrandr.

$ sudo apt-get install arandr
$ arandr

Then you can set up your desired config, save it to a file somewhere, then look at that file to find out what xrandr command is needed to get the setup you want.


At least on my setup, I can switch monitor mirroring on with this command:

xrandr --output HDMI1 --same-as DP1

To turn off monitor mirroring, I use this command:

xrandr --output HDMI1 --pos 1920x0

In other words, I don't need to re-specify settings such as "--mode 1920x1080" and "--rotate normal". Simply changing between "--same-as" and "--pos" has been sufficient, at least in my case.

These commands have been handy for me when viewing my workplace screens from a remote laptop. My workplace screens are on a dual-monitor setup running Linux Mint, so I need an easy way to temporarily switch to mirror mode during my remote session. I can also switch mirroring on and off using the "Super-p" (Windows-p) Cinnamon keyboard shortcut ("Re-detect display devices"), but the keyboard approach sometimes crashes my VNC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.