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?
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?
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 ~/.config/autostart/lxrandr-autostart.desktop
.
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
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>
</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 xrandr -q
.)