How to use shortcuts to switch between displays in LXDE? I mean to switch between the laptop monitor and an external display.

I edited /home/user/.config/openbox/lubuntu-rc.xml file to set shortcuts but how to do it for this specific purpose?

3 Answers 3


If you want dual monitor functionality in Lubuntu, you have limited options. The following will show you how to enable and disable dual monitors "on the fly" using ARandR as help. These directions are a bit complicated, but trust me: they are not dangerous. This is a SAFE operation.

First, get ARandR from Synaptic or by opening the terminal and pasting:

sudo apt-get install arandr

You can find your new application under Menu -> Preferences

enter image description here

What you see is a virtual setup of your monitor arrangement. You will almost certainly have different names for your monitor, but here is what mine looks like.

enter image description here

Although you haven't really done anything at this point, save this configuration.

enter image description here

It will automatically create a new hidden folder called .screenlayout in your home directory. I would encourage you to not change the file location to help with later steps. I would also encourage you to use my file names as well. This one should be called single.

enter image description here

Now add your second monitor. It should be hooked up to your computer at this point, of course. I added mine by scrolling through the only other monitors that allowed activation and selected it.

enter image description here

Position the monitors however you like. I prefer side-by-side, but you may also put one above the other. It doesn't matter which one is on the left (or the top). It's all up to you! Here's what I like:

enter image description here

Once you have your desired configuration, save it again. This time, name the file dual.

The last step in this whole process is creating hotkeys to switch monitor on the fly. In the terminal type in the following:

sudo leafpad ~/.config/openbox/lubuntu-rc.xml

Scroll down to a place where you begin to see a lot of words that say <keybind>. You don't need to know what's happening here. Simply find a place after a </keybind>, but before the next <keybind> and paste the following:

<keybind key="W-2">
<action name="Execute">
<command>sh ~/.screenlayout/dual.sh</command>

<keybind key="W-1">
<action name="Execute">
<command>sh ~/.screenlayout/single.sh</command>

Your code should look a little like this:

enter image description here

Save. Close. Logout.

If you did everything right, you should be able to press Super+2 to activate dual monitor mode. To go back to one monitor, such as your laptop, press Super+1.

One final note about the lxde panel. When I switched into dual mode, my panel looked a little funny. If you experience this problem, open up your files you created with ARandR in the .screenlayout directory. Add the following lines to the bottom of the files:

lxpanelctl restart

Check out this page I wrote up a few months back.

Good luck.

  • I wish I could post pictures straight into the post, but I don't have enough "cred" I guess... Sorry. Jul 10, 2012 at 19:38
  • Thank you. It works. Your pictures in the blog are very useful anyway. I have no doubts your 'reputation' will soon increase here.- I have done some variations from what you recommended, using different keys, and adding a third one just for the external display (which in this way can have the proper resolution; for some reason the resolution saved in the 'dual' file - according to the blog - is not respected). Adding 'lxpanelctl restart' in each of the files is needed.You should edit your answer to match more closely your answer in the blog. Or maybe I could do that.
    – user47206
    Jul 12, 2012 at 16:03
  • It is possible to have a third option in which the second monitor is the only one active. That should be accessed with a third keyboard shortcut. In each case you can also save the resolution for the respective monitors. - Adding also 'lxpanelctl restart' is necessary.
    – user47206
    Jul 12, 2012 at 16:48
  • It is your answer and you can change it as you like (in fact I was not permitted to correct the final part - a space missing between final phrases - as the edit would have been too short: maybe you can.)
    – user47206
    Jul 12, 2012 at 23:33

The idea is to use xrandr commands. But how to find the proper commands?

I have found a simple solution as a result of this answer.

Simpler, because involves using the LXDE default display manager, LXRandr, without the need of scripts.

It can save configurations (which are xrandr configurations).

enter image description here

When it saves the present configuration the older one is overwritten. But finding them and using them as shortcuts is a nice way to achieve what we want here.

The save is in ~/.config/autostart/lxrandr-autostart.desktop.

The file looks like

[Desktop Entry]
Name=LXRandR autostart
Comment=Start xrandr with settings done in LXRandR
Exec=xrandr --output LVDS --mode 1680x1050 --rate 60.1 --output VGA-0 --off

So, to save a certain configuration, open that file in a text editor like gedit

gedit ~/.config/autostart/lxrandr-autostart.desktop

and save the line after Exec=, which is a command to be run with a shortkey.

Creating shortcuts in LXDE is presented in the other answer, that is by editing the file ~/.config/openbox/lubuntu-rc.xml.

For example, in order to run the command above with the shortkey Ctrl-M , the edit should be like so:

<!-- Internal monitor only -->
    <keybind key="C-m">
      <action name="Execute">
        <command>xrandr --output LVDS --mode 1680x1050 --rate 60.1 --output VGA-0 --off</command>

For each computer and its specific internal+external display there should be three basic configurations (internal display only, external only, and both on); and others more only in case of various resolution settings for each of these three.

I found here that in order to have extended monitor (which is outside the capabilities of LXRandr) the command should be something like

xrandr --output VGA-0 --auto --left-of LVDS

(VGA-0 and LDTS are variables, look in ~/.config/autostart/lxrandr-autostart.desktop to see what you have, or run xrandr -q.)


Disable the Super_L entry in your Global Actions Manager (search for "Shortcut Keys" in your Application Menu)

"Super_L" row option deselected in the Global Actions Manager

Run sudo featherpad ~/.config/openbox/lxqt-rc.xml or sudo nano ~/.config/openbox/lxqt-rc.xml.

Search for the <keyboard> tag using the shortcut CTRL + F if you're using featherpad or CTRL + W if you're using nano editor. Insert this after the keyboard tag:

<!-- Move the window to the first monitor -->
<keybind key="W-S-Left">
    <action name="MoveResizeTo">
<!-- Move the window to the second monitor -->
<keybind key="W-S-Right">
    <action name="MoveResizeTo">
  1. Change the keybinding from W-S-Right to W-S-Left depending on your window order configuration. These keybindings are the equivalent to Windows + Shift + Left arrow key and Windows + Shift + Right arrow key on your keyboard.

Save it and run openbox --reconfigure in your terminal.

Working on Lubuntu 21.10

  • Lubuntu 21.10 runs LXQt, not LXDE. Dec 23, 2021 at 20:30

You must log in to answer this question.