6

On my laptop with 14.04, I want to use an external monitor. I want to put my external monitor on the left side but ubuntu seems to logically put it on the right side. I tried to organize the display placements, but when I drag built in monitor to the right all my desktop icons moves to the external monitor. How can I solve this issue. Default display organization

muctadir@muctadir-laptop:~$ xrandr --prop 
Screen 0: minimum 8 x 8, current 3286 x 1080, maximum 32767 x 32767
LVDS1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
    EDID: 
        00ffffffffffff0006afec4501000000
        01150103802213780a0bb59757548c26
        23505400000001010101010101010101
        010101010101121b566050001630080a
        310058c1100000180000000f00000000
        00000000000000000020000000fe0041
        554f0a202020202020202020000000fe
        004231353658573034205635200a0046
    BACKLIGHT: 976 
        range: (0, 976)
    Backlight: 976 
        range: (0, 976)
    scaling mode: Full aspect 
        supported: None, Full, Center, Full aspect
   1366x768       60.0*+
   1360x768       59.8     60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1920x1080+1366+0 (normal left inverted right x axis y axis) 160mm x 90mm
    EDID: 
        00ffffffffffff004c2dcd053432524c
        12140103801009782a6041a6564a9c25
        125054230800a9408180814081009500
        b30001010101023a801871382d40582c
        4500a05a0000001e011d007251d01e20
        6e285500a05a0000001e000000fd0032
        3c1e5111000a202020202020000000fc
        0053796e634d61737465720a2020018f
        02031cf14890041f0514130312230907
        078301000066030c00100080011d80d0
        721c1620102c2580a05a0000009e011d
        8018711c1620582c2500a05a0000009e
        011d00bc52d01e20b8285540a05a0000
        001e8c0ad090204031200c405500a05a
        000000188c0ad08a20e02d10103e9600
        a05a0000001800000000000000000046
    Broadcast RGB: Automatic 
        supported: Automatic, Full, Limited 16:235
    audio: auto 
        supported: force-dvi, off, auto, on
   1920x1080      60.0*+   50.0     59.9  
   1920x1080i     60.1     50.0     60.0  
   1600x1200      60.0  
   1680x1050      59.9  
   1280x1024      60.0  
   1440x900       59.9  
   1280x960       60.0  
   1280x800       59.9  
   1280x720       60.0     50.0     59.9  
   1024x768       60.0  
   800x600        60.3     56.2  
   720x576        50.0  
   720x480        60.0     59.9  
   640x480        60.0     59.9  
DP1 disconnected (normal left inverted right x axis y axis)
    Broadcast RGB: Automatic 
        supported: Automatic, Full, Limited 16:235
    audio: auto 
        supported: force-dvi, off, auto, on
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
  • Do you mean you don't want icons on the left screen anyway, or do you want to keep (restore) the positions of the icons when you connect the screen? – Jacob Vlijm May 24 '15 at 5:11
  • The latter can be done :) please let me know. – Jacob Vlijm May 24 '15 at 8:54
  • I want everything to stay on my laptop display when I connect my external display. – Hossain Muctadir May 24 '15 at 10:11
5

The screen icons in the system settings can actually be dragged, so you can place the green Samsung on the left. Alternatively, you can use this command:

xrandr --output HDMI1 --mode 1024x768 --pos 0x0 --rotate normal \
       --output LVDS1 --mode 1366x768 --pos 1024x0 --rotate normal

I use this command (with different outputs of course) to position my screen, VGA to the left, internal monitor to the right, on graphical login.

Alternativelly, you can look into lxrandr program, which does exactly same job as Ubuntu's settings, but may be a little less confusing.

  • You might need to modify the command to fit your needs, but that should pretty much work – Sergiy Kolodyazhnyy May 23 '15 at 19:57
  • Thank you. I already know that and already mentioned it in my question which you might have missed. – Hossain Muctadir May 24 '15 at 0:00
  • @Muctadir I misssed that, indeed. Have you tried the command ? Also about your icons, that's normal behavior, and I doubt there's much what you can do. My dual screen setup behaves the same – Sergiy Kolodyazhnyy May 24 '15 at 0:28
1

Unfortunately, there is no way to make the monitor settings understand you have your external screen on the left and you want the right screen to be the "main" screen, and the "home" location for your desktop icons.

That does not mean however that you are convicted to dragging and rearranging your icons every time your second screen is connected or disconnected.

How to save yourself the time to manually rearrange your desktop items

With the script below (under a shortcut key), you can take a "snapshot" of the way your icons are arranged on your desktop (you only need to do this once).

With a second shortcut key, this snapshot will be "converted" to the new situation when a second screen is attached, and vice versa; your icons will always be on your main screen, arranged according to the snapshot.

The advantage is that the solution will work no matter what your screen setup is, and no matter how the screens are alligned. You can even change that, the script will calculate the setting and the positions of your icons.

How it works in practice

  1. Press a key combination (1) to take a snapshot of the current desktop icon arrangement (as mentioned, you only need to do this once). This arrangement will be remembered in a hidden file
  2. Now attach your second screen, make any setup you'd like (left/right, top alligned or not, all is possible). Your desktop will be messed up.
  3. Press another key combination (2), to "translate" your desktop layout to the new setup. Your icons will be moved to your built-in screen on the right as if no second screen was connected. Click on the desktop and subsequently press F5 to refresh the desktop (else you won't see the changes).

If you disconnect the second screen, your desktop will be messed up again. Simply press key combination (2), click on the desktop and press F5 again to restore the layout again.

How to set up

  1. Copy the script below into an empty file, save it as arrange_desktop.py
  2. In the head section of the script, set the name of your "main" screen (use the xrandr command to find out). This will probably be your built-in screen. I already set it to the output of xrandr in your question.
  3. Arrange your desktop icons as you like
  4. Test-run the script:

    • Run it from a terminal by the command:

      python3 /path/to/arrange_desktop.py snapshot
      
    • You'll see a notification:

      enter image description here

    • Now connect the second screen, set it up as you want, your icons will be messed up.

    • Now run the script again, with the option restore:

      python3 /path/to/arrange_desktop.py restore
      
    • You'll see a notification:

      enter image description here

    • Click on the desktop (anywhere) and press F5, your icons will be arranged according the snapshot on the main screen (the right one in your case), no matter what is the current screen setup.

    • If all works fine, create two shortcut keys for the commands:

      python3 /path/to/arrange_desktop.py snapshot
      

    and

        python3 /path/to/arrange_desktop.py restore
    

    and you'll be done. Now you can fix your desktop layout both ways (connect-disconnect) with a simple key combination.

Notes

  • No need to say that if you change thge desktop arrangement and you want it to be remembered, take a snapshot again.
  • You can take a snapshot while the second screen is attached or not, the script calculates the icon positions correctly to the "main" screen.

The script

#!/usr/bin/env python3
import subprocess
import time
import os
import sys

#--- set the localized name of your desktop below (if necessary)
dt_name = "Desktop"
#--- set the name of the "main" screen below (replace "DVI-I-1")
screen = "LVDS1"
#---

arg = sys.argv[1]

# used strings & definitions
val = " 'metadata::nautilus-icon-position' "
search = "gvfs-info -a"+val
set_val = "gvfs-set-attribute -t string "
home = os.environ["HOME"]
dt_dir = os.environ["HOME"]+"/"+dt_name
datafile = home+"/.desktop_items.txt"

# functions
get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")

def scr_data():
    scr = [l.split() for l in get("xrandr").splitlines() if screen in l][0]
    return [int(n) for n in [s for s in scr if all(["+" in s, "x" in s])][0].split("+")[-2:]]

# take a snapshot of the icon layout
if arg == "snapshot":
    screen_pos = scr_data()
    try:
        os.remove(datafile)
    except FileNotFoundError:
        pass
    dt_items = os.listdir(dt_dir)
    dt_data = []
    for f in [f for f in dt_items if all([not f.startswith("."), not f.endswith("~")])]:
        f = '"'+f+'"' if f.count(" ") > 0 else f
        file = dt_dir+"/"+f
        cmd = search+file
        try:
            loc = [int(n) for n in get(cmd).split()[-1].split(",")]
            loc[0] = loc[0] - screen_pos[0]; loc[1] = loc[1] - screen_pos[1]
            loc = (",").join([str(n) for n in loc])
            open(datafile, "a+").write(file+"|||"+loc+"\n")
        except:
            pass
    subprocess.Popen(["/bin/bash", "-c", "notify-send 'A snapshot was taken'"])

# restore icons
elif arg == "restore":
    vector = scr_data()
    items = [l.strip().split("|||") for l in open(datafile).readlines()]
    for item in items:
        try:
            xy = [int(n) for n in item[1].split(",")]
            move_to = (",").join(str(n) for n in [vector[0]+xy[0], vector[1]+xy[1]])
            command = set_val+item[0]+val+move_to
            subprocess.Popen(["/bin/bash", "-c", command])
        except:
            pass
    subprocess.Popen(["/bin/bash", "-c", "notify-send 'Click on the desktop and press F5'"])
  • Thank you very much. But, it looks like way too much overhead. – Hossain Muctadir May 25 '15 at 21:32
  • @Muctadir ?? The work is already done, you job is to push two buttons. – Jacob Vlijm May 26 '15 at 0:57
0

I have this problemin virtuabox the solution , change the screen between monitors.

  • The primary screen move to your Build-in Display
  • The secondary screen move to your Samsumg display

Other mode in Ubuntu is change xml monitors :

    gedit ~/.config/monitors.xml 

And edit :

    <primary>yes</primary> <!-- For primary monitor -->
    <primary>no</primary> <!-- For not primary monitor -->
  • Thanks. But, these properties were already set in the xml. – Hossain Muctadir May 23 '15 at 14:19
  • Ok , i have this problem , but in virtual machine is easy get solution. I am searching. – CodeNoob May 23 '15 at 18:43
0

You can use arandr that is an easy-to-use tool.

  • install with sudo apt-get install arandr
  • run arandr and the GUI will come up

drag the displays to fit them as you like e.g.

arandr gui

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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