linuxubuntuxserver

Linux retrieve monitor names


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

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.

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.


Solution

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

    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 = "";
    }'