Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to realize screen selection function in CentOS

Shulou Source: shulou.com Published: 2022-06-01 14:37:43 09月17日 Update

In this issue, the editor will bring you about how to achieve screen selection function in CentOS. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

[root@localhost ~] # vim load_xrandr.py# -.-coding:utf-8 -.-_ author__ = 'root' import os # list the monitor and resolution getScreens = os.popen ("vgas=$ (xrandr | grep" connected "); [$(echo" $vgas "| wc-l)-gt 1] & & {for i in $(echo" $vgas "| awk' {print $1}') Do echo $I xrandr | grep "$I connected"-A1 | awk-F "x"'{print $1}'| tail-n 1 | sed "s / g" done} "). Readlines () # handles the newline symbol for i in range (len (getScreens)): getScreens [I] = getScreens [I] .repla ce ("\ n ") ") # compare the higher resolution display if int (getScreens [1]) < int (getScreens [3]): bigger = getScreens [2] little = getScreens [0] else: bigger = getScreens [0] little = getScreens [2] # use the larger monitor as the current output. Os.popen (" xrandr-output% s-auto-output% s-off "% (bigger, little))

After writing this code, you can output the screen to a larger screen as long as you load it when you log in.

[root@localhost ~] # vim .bashrc [$(xrandr | grep "connected" | wc-l)-gt 1] & & {/ usr/local/Python-2.7.8/bin/python / root/load_xrandr.py} this is how screen selection is implemented in the CentOS shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis for understanding. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Screen display function selection large content resolution analysis output professional small and medium code rich in content that is newline characters articles time display more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi MariaDB vpn Huawei