How to use shortcuts to switch between displays in LXDE? I mean to switch between the laptop monitor and an external display.
/home/user/.config/openbox/lubuntu-rc.xml file to set shortcuts but how to do it for this specific purpose?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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
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.
Although you haven't really done anything at this point, save this configuration.
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
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.
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:
Once you have your desired configuration, save it again. This time, name the file
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> </action> </keybind> <keybind key="W-1"> <action name="Execute"> <command>sh ~/.screenlayout/single.sh</command> </action> </keybind>
Your code should look a little like this:
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:
Check out this page I wrote up a few months back.
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).
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
The file looks like
[Desktop Entry] Type=Application Name=LXRandR autostart Comment=Start xrandr with settings done in LXRandR Exec=xrandr --output LVDS --mode 1680x1050 --rate 60.1 --output VGA-0 --off OnlyShowIn=LXDE
So, to save a certain configuration, open that file in a text editor like gedit
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
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> </action> </keybind>
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