Linux检索监视器名称 [英] Linux retrieve monitor names

查看:55
本文介绍了Linux检索监视器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:我正在使用多个监视器,我想用bash来获取它们的名称.目前,我正在使用Ubuntu 10.04.

Situation: I'm using multiple monitors and I want to get their names in bash. Currently I'm using Ubuntu 10.04.

我了解xrandr.从中我只能得到统计数据.我想要的是读取数组中的所有监视器名称以使用它们.

I know about xrandr. From it I can get only statistics data. What I want is to read all monitor names in an array to work with them.

是否有一种清晰的方法可以在不删除某种字符串名称的情况下做到这一点?一种清晰的方法是从文件中读取它们.一种不清楚的方法是将xrandr输出传递给某种函数以从中删除名称.

Is there a clear way to do that without cutting names from some kind of string? A clear way would be reading them from file. A not clear way would be to pipe xrandr output to some sort a function to cut names out from it.

推荐答案

sudo get-edid 对我不起作用.(现在可以在另一台计算机Lubuntu 14.10上运行;我要怪BIOS的差异,但这是一个随机的猜测...)

sudo get-edid didn't work for me. ( now works on another computer, Lubuntu 14.10; I'd blame BIOS differences but that's a random guess...)

无论如何在X下, xrandr --verbose 都会打印EDID块.这是一种提取它并传递给 parse-edid 的快捷方法:

Anyway under X, xrandr --verbose prints the EDID block. Here is a quick and dirty way to extract it and pass to parse-edid:

#!/bin/bash
xrandr --verbose | perl -ne '
if ((/EDID(_DATA)?:/.../:/) && !/:/) {
  s/^\s+//;
  chomp;
  $hex .= $_;
} elsif ($hex) {
  # Use "|strings" if you dont have read-edid package installed 
  # and just want to see (or grep) the human-readable parts.
  open FH, "|parse-edid"; 
  print FH pack("H*", $hex); 
  $hex = "";
}'

这篇关于Linux检索监视器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆