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've searched for something similar to this problem and I didn't find it. I apologise if it's a duplicate.

I'm trying Xubuntu installed ontop of my Ubuntu 13.10. I've been trying to connect an external monitor and extend the desktop. It worked, no complains there. This is the result (left: latop - right: 24" VGA external monitor):

http://i.stack.imgur.com/kXcAs.png

However, when I go back to the laptop screen only the menu bar disappears, as shown on the next screenshot:

http://i.stack.imgur.com/d7ysw.png

If I plug in/activate the external monitor again it goes back to work normally as shown earlier.

Update:

output of xrandr as requested (no external monitor)

Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 32767 x 32767
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 277mm x 156mm
   1366x768       60.0*+
   1360x768       59.8     60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected 1920x1080+1366+0 (normal left inverted right x axis y axis) 0mm x 0mm
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
  1920x1080 (0x4d)  148.5MHz
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock   67.5KHz
        v: height 1080 start 1084 end 1089 total 1125           clock   60.0Hz

External monitor plugged in:

Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 32767 x 32767
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 277mm x 156mm
   1366x768       60.0*+
   1360x768       59.8     60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 connected 1920x1080+1366+0 (normal left inverted right x axis y axis) 531mm x 299mm
   1920x1080      60.0*+
   1600x1200      60.0  
   1680x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       59.9  
   1280x960       60.0  
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        75.0     72.8     66.7     60.0  
   720x400        70.1  
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
share|improve this question
    
Rebooting doesn't help. The menu doesn't come back unless I plug in the external monitor. –  davidfm Mar 16 at 16:18
    
What exactly does "on top of" mean? Please post the output of xrandr. Can you confirm that when you unplug the monitor, your system still thinks it's there? Your desktop is still being extended to the right despite the absence of the screen. Is this correct? –  terdon Mar 16 at 16:36
    
"on top of" means I had Ubuntu and installed xubuntu-desktop afterwards. Yes, that seems to be the case. –  davidfm Mar 16 at 16:43
    
Please show the xrandr output with both screens connected. I assume your external one is the VIRTUAL1 is that correct? –  terdon Mar 16 at 16:48
    
Based on what I see I'd say the external one is VGA1. –  davidfm Mar 16 at 16:58

1 Answer 1

up vote 0 down vote accepted

OK, the issue is that when you unplug the monitor, your desktop settings are not refreshed and the system still thinks it has a second monitor attached. This can probably be fixed using udev rule but they can get complicated for this kind of thing. I have written a little script that refreshes my desktop and I have mapped it to a shortcut key so I can easily run it and fix this type of issue. I have modified it to match your setup based on the output of your xrandr

#!/usr/bin/env bash


## If the VGA1 screen is currenlty connected  
if ( xrandr | grep VGA1 | grep -qw connected )
then
    ## print a pretty message
    notify-send "Extending desktop to screen VGA1"

    ## extend the desktop to the external screen. If you want your panel
    ## to appear on the right hand screen move the '--primary' flag to
    ## the VGA1: --output VGA1 --primary ...
    xrandr --output LVDS1 --auto  --primary --output VGA1 --auto --right-of LVDS1
else

    ## If the external screen is not connected, refresh the desktop and
    ## make everything appear on the laptop's
    xrandr --output LVDS1 --auto --primary --output VGA1 --off

fi

Save this script as ~/screen_switch.sh, make it executable (chmod +x ~/screen_switch.sh) and then use the System Settings to set a keyboard shortcut that runs it. You can now use the shortcut to fix your problem.

share|improve this answer
    
I'll try it right away. –  davidfm Mar 16 at 16:59
    
I changed VIRTUAl1 to VGA1 and it worked like a charm. Thanks very much :) –  davidfm Mar 16 at 17:04
    
@davidfm you're very welcome. I've also updated my answer accordingly. –  terdon Mar 16 at 17:04

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.