CentOS "screen selection" function (display)
A CentOS6.5 is installed in the notebook, and the notebook usually has an external display. After the system is installed, the "screen selection" function (display) will never be found when the mouse is shaking for a while ), the following code is available in anger.
[root@localhost~]
#vimload_xrandr.py
#-.-coding:utf-8-.-
__author__
=
'root'
import
os
# List displays and resolutions
getScreens
=
os.popen(
"""
vgas=$(xrandr|grep"connected");
[$(echo"$vgas"|wc-l)-gt1]&&{
foriin$(echo"$vgas"|awk'{print$1}');
do
echo$i
xrandr|grep"$iconnected"-A1|awk-F"x"'{print$1}'|tail-n1|sed"s///g"
done
}"""
).readlines()
# Handling line breaks
for
i
in
range
(
len
(getScreens)):getScreens[i]
=
getScreens[i].replace(
"\n"
,"")
# Display with a higher resolution than the output
if
int
(getScreens[
1
])<
int
(getScreens[
3
]):
bigger
=
getScreens[
2
]
little
=
getScreens[
0
]
else
:
bigger
=
getScreens[
0
]
little
=
getScreens[
2
]
# Use a large display as the current output.
os.popen(
"xrandr--output%s--auto--output%s--off"
%
(bigger,little))
After writing this code, you only need to load it at login, and the screen can be output to a relatively large display.
[root@localhost~]
#vim.bashrc
[$(xrandr|
grep
"connected"
|
wc
-l)-gt1]&&{
/usr/local/Python-2
.7.8
/bin/python
/root/load_xrandr
.py
}
Later, we found that the Display is in the System-> Preferrences panel.