Solution anyone for a newb? I connect my notebook to external monitor with HDMI. I switch off screen notebook since I'm not using it. Ubuntu 15.04 remembered this setting after reboot, but with 15.10 I have to change this setting every time. Does anyone know how to fix this?
-
Is the monitor always connected? – Jacob Vlijm Mar 20 '16 at 19:56
-
yes, it is always conneced. and switched on before i boot. – FrankThuis Mar 20 '16 at 20:03
-
Just posted my answer. Let me know if you manage! – Jacob Vlijm Mar 20 '16 at 20:46
1 Answers
The issue is pretty sure the result of a bug, but easily fixed on log in.
What to do
Copy the script below into an empty file, save it as
set_screen.py
#!/usr/bin/env python3 import subprocess import time #--- set the name of your internal screen below internal = "DVI-I-1" #--- time.sleep(10) extr = [l.split()[0] for l in subprocess.check_output("xrandr").decode("utf-8").splitlines() if " connected" in l\ and not internal in l] if extr: subprocess.Popen(["xrandr", "--output", internal, "--off", "--output", extr[0], "--auto"])
Get your internal screen's name: open a terminal window: press Ctrl+Alt+T, and type the command
xrandr
and press Enter. Among the lines in the output, there is one line looking like:
DVI-I-1 connected 1680x1050+0+0 (normal left inverted right x axis y
You need to look at the first string, like
DVI-I-1
, this is your internal screen's name (obviously, you do not pick the one withHDMI
in it :) )Enter the name you found in the head of the script, in the line:
internal = "DVI-I-1"
between quotes, like in the example.
Test- run the script with the command (again, from the terminal window):
python3 /path/to/set_screen.py
(where you obviously need to replace
/path/to
by the actual path) After ten seconds, the internal screen should shut down, while the external screen stays.If all works fine, add it to Startup Applications: open Dash > Startup Applications > Add. Add the command:
python3 /path/to/set_screen.py
From now on, within a few seconds after log in, your internal screen will shut down.

- 83,767
-
thank you. I will give it a try, hopefully tonight. surprised that a work-around is necessary. curious to find out if this will also change the desktop size at the same time (which in fact is the reason that I manually have to switch off the internal screen) – FrankThuis Mar 20 '16 at 21:06
-
@FrankThuis Ah, you didn't mention that. If the resolution is incorrect, you need to post the outpu of xrandr with a correct screen setup. – Jacob Vlijm Mar 20 '16 at 21:08
-
Your script works flawlessly when I run it manually. Even the desktop size seems to be fine. [internal = "LVDS" & /usr/bin/set_screen.py ]. It doesnt seem to be working on startup and I still have to enter my password on the internal screen, but hey, its a work-around and beggars cannot be choosers. Maybe sth. with rights, but a link on somewhere works just as fine. So all in all, thank you. You gained an admirer. – FrankThuis Mar 20 '16 at 21:39
-
1I have done so. (And will do likewise in the future.) Thanks again. – FrankThuis Mar 20 '16 at 21:45
-
@FrankThuis The internal screen should indeed switch off after log in, since Startup Applications works on log in. If it doesn't within 10 seconds or so, you need to increase the time in the line
time.sleep(10)
to (e.g.)time.sleep(15)
– Jacob Vlijm Mar 20 '16 at 21:45 -
An alternative: http://askubuntu.com/questions/740004/how-can-i-automatically-switch-off-internal-screen-when-an-external-screen-is-co/740140#740140 This works also if you disconnect / connect again the screen. – Jacob Vlijm Mar 20 '16 at 21:47