Is there an equivalent to windows+p hotkey (change between mirrored/extended monitor) in Ubuntu?
Solution 1:
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.