
查找笔记本电脑显示器尺寸的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
(连接之前请注意空格电脑显示器尺寸哪里看,否则将包括断开连接的地方)
这似乎与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]]))
根据要求(在注释中)的“种类”,经过现代化/更高级/改进(没有系统调用,没有解析,但使用Gdk.Display)版本,几乎完全相同:
#!/usr/bin/env python3
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk
dsp = Gdk.Display.get_default()
n_mons = dsp.get_n_monitors()
print(("\t").join(["Screen", "width", "height", "diagonal\n"+32*"-"]))
for i in range(n_mons):
mon = dsp.get_monitor(i)
mon_name = mon.get_model()
w = mon.get_width_mm()/25.4
h = mon.get_height_mm()/25.4
d = ((w**2)+(h**2))**(0.5)
print(("\t").join([mon_name]+[str(round(n, 1)) for n in [w, h, d]]))
输出:

Screen width height diagonal
--------------------------------
eDP-1 20.0 11.3 23.0
HDMI-1 18.6 11.7 22.0
我将保留原始答案,因为过了这么长时间后删除答案似乎不合适,这会产生现有的投票.
如果您想得到更一般的答案,则可以切开gordian结电脑显示器尺寸哪里看,并使用非怪异的物理尺子. 根据此Wiki的说法,“屏幕尺寸通常由其对角线的长度来描述”:

如果您的标尺仅显示厘米,则可以使用简单的转换:
1 cm = 0.393701 in
(or 2.54 cm = 1 in)
因此,如果您的标尺尺寸为30厘米,则屏幕为11.811英寸. 您也可以使用30厘米长的Google进行格式查询.
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/sanxing/article-184872-1.html