Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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]
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.)

share|improve this answer
add comment

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>
</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:

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.

share|improve this answer
    
I wish I could post pictures straight into the post, but I don't have enough "cred" I guess... Sorry. –  algebralives Jul 10 '12 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. –  cipricus Jul 12 '12 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. –  cipricus Jul 12 '12 at 16:48
    
Thanks, cipricus, for the edits. It looks great. –  algebralives Jul 12 '12 at 20:12
    
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.) –  cipricus Jul 12 '12 at 23:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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