如何才能获得笔记本电脑的显示器尺寸?

什么是Ubuntu linux命令来查找笔记本电脑的显示器尺寸? 如果可能的话,我想用英寸知道。

谢谢

使用xrandr另一个选项是命令:

 xrandr | grep ' connected' 

输出:

 DVI-I-1 connected primary 1680x1050+0+0 (normal left inverted right x axis y axis) 473mm x 296mm VGA-1 connected 1280x1024+1680+0 (normal left inverted right x axis y axis) 376mm x 301mm 

(注意connected前的空间,否则将包括disconnected

xdpyinfoxrandr之间的重要区别

  • 虽然xrandr单独列出屏幕(如果是多个显示器), xdpyinfo为所有屏幕输出一组维度(“桌面大小”而不是屏幕大小)
  • 正如@agold所注意到的那样,两者之间存在(相当)差异,这看起来太大而不能成为一个简单的舍入差异:

     xrandr: 473mm x 296mm xdpyinfo: 445x278 

它似乎与xdpyinfo 的错误有关。 另见这里 。

如果你坚持英寸

使用下面的小脚本; 它以英寸为单位输出屏幕尺寸; 宽度/高度/对角线(英寸)

 #!/usr/bin/env python3 import subprocess # change the round factor if you like r = 1 screens = [l.split()[-3:] for l in subprocess.check_output( ["xrandr"]).decode("utf-8").strip().splitlines() if " connected" in l] for s in screens: w = float(s[0].replace("mm", "")); h = float(s[2].replace("mm", "")); d = ((w**2)+(h**2))**(0.5) print([round(n/25.4, r) for n in [w, h, d]]) 

要使用它:

将脚本复制到空文件中,将其另存为get_dimensions.py ,然后通过以下命令运行:

 python3 /path/to/get_dimensions.py 

我的两个屏幕输出:

 width - height - diagonal (inches) [18.6, 11.7, 22.0] [14.8, 11.9, 19.0] 


编辑

同一个脚本的精美版本(有一些改进和更好的输出),看起来像:

 Screen width height diagonal -------------------------------- DVI-I-1 18.6 11.7 22.0 VGA-1 14.8 11.9 19.0 

剧本:

 #!/usr/bin/env python3 import subprocess # change the round factor if you like r = 1 screens = [l.split() for l in subprocess.check_output( ["xrandr"]).decode("utf-8").strip().splitlines() if " connected" in l] scr_data = [] for s in screens: try: scr_data.append(( s[0], float(s[-3].replace("mm", "")), float(s[-1].replace("mm", "")) )) except ValueError: pass print(("\t").join(["Screen", "width", "height", "diagonal\n"+32*"-"])) for s in scr_data: scr = s[0]; w = s[1]/25.4; h = s[2]/25.4; d = ((w**2)+(h**2))**(0.5) print(("\t").join([scr]+[str(round(n, 1)) for n in [w, h, d]])) 

如果你想要一个更一般的答案,你可以削减gordian结 ,并使用一个非怪异的物理标尺 。 根据这个wiki ,“屏幕的大小通常用对角线的长度来描述”:

在此处输入图像描述

如果您有一个仅显示厘米的标尺,您可以使用简单的转换 :

 1 cm = 0.393701 in (or 2.54 cm = 1 in) 

因此,如果您的标尺尺寸为30厘米 ,则屏幕为11.811英寸。 您还可以使用谷歌查询30 cm to in的表格。


图片来源: https ://en.wikipedia.org/wiki/File: Display_size_measurements.png

Xdpyinfo是一个用于显示有关X服务器的信息的实用程序。 它用于检查服务器的function,客户端和服务器之间通信中使用的各种参数的预定义值,以及可用的不同类型的屏幕和视觉效果。

获取监视器大小的命令是:

 xdpyinfo | grep dimensions 

结果

 dimensions: 1366x768 pixels (361x203 millimeters)