multiple monitors - How to make VGA output display above my main screen by default? - Ask Ubuntu


my vga output (vga-1 configured @ right of main screen (lvds-1).

how can configure system vga ouput above main screen default?


ps:

to put vga above, use

xrandr --output vga-1 --auto --above lvds-1 

the issue screen layout doesn't stick result of minor bug, however:

you have 2 options:

1. run background script run command automatically once second screen connected:

#!/usr/bin/env python3 import subprocess import time  #--- set both commands (connect / disconnect) below connect_command = "gedit" disconnect_command = "" #---  # function output of xrandr def get(cmd): return subprocess.check_output(cmd).decode("utf-8") # - count occurrenc of " connected " def count_screens(xr): return xr.count(" connected ") # - run connect / disconnect command(s) def run_command(cmd): subprocess.popen(cmd)  # first count xr1 = count_screens(get(["xrandr"]))  while true:     time.sleep(5)     # second count     xr2 = count_screens(get(["xrandr"]))     # check if there change in screen state     if xr2 != xr1:         if xr2 == 2:             # command run if connected (two screens)             run_command(["xrandr", "--output", "vga-1", "--auto", "--above", "lvds-1"])         elif xr2 == 1:             # command run if disconnected (one screen)             # uncomment run_command(disconnect_command) enable, comment out pass             pass             # run_command(disconnect_command)     # set second count initial state next loop     xr1 = xr2 

the script outtake of this one.

to use it

  • copy script empty file, save setup_scr.py
  • test-run command:

    python3 /path/to/setup_scr.py 
  • if works should, add startup applications: dash > startup applications > add. add command:

    /bin/bash -c "sleep 15 && python3 /path/to/setup_scr.py" 

2. add command shortcut, press after connect second screen:

add shortut key: choose: system settings > "keyboard" > "shortcuts" > "custom shortcuts". click "+" , add command:

python3 /path/to/setup_scr.py 

notes

  • the script covers both running commands on connect- , disconnecting screen, left was, have options.
  • i couldn't test, since don't have second screen attached currently. should work fine, sensitive blind spots , typos...
  • the script, is, assumes no errors occur, means defined screen should (external) screen use. if not case, should build in either conditional or try/except. if so, please mention.

    in case of errors, please let me know.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User