Last active
September 3, 2022 15:30
-
-
Save joevt/e862b0088ef58b9144877d01401bcee8 to your computer and use it in GitHub Desktop.
Revisions
-
joevt revised this gist
Jan 7, 2021 . 1 changed file with 39 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,40 @@ #!/bin/bash # by joevt Jan 7/2021 dodump=1 if [[ "$1" == "-s" ]]; then dodump=0 shift fi plisttojson () { local theparam="" if [[ "$1" == "-r" ]]; then theparam="$1" shift fi local sedscript=' /^'$'\t''*<data>/,/^'$'\t''*<\/data>/ { /^('$'\t''*)<data>(.*)/ { s//\1<string>_data:\2/; h; d; }; /^'$'\t''*<\/data>(.*)/! { s/^'$'\t''+(.*)/\1/; H; d; }; /^'$'\t''*<\/data>(.*)/ { s//:data_<\/string>\1/; H; g; s/\n//g; }; } ' { if [[ -n "$1" ]]; then sed -E "$sedscript" "$1" else sed -E "$sedscript" fi || { echo "# sed failed" 1>&2 ; return 1 ; } } | { plutil -convert json $theparam - -o - || { echo "# plutil failed" 1>&2 ; return 1 ; } ; } return 0 } dumpM1MacTimings () { local theplist="$1" @@ -17,13 +51,7 @@ dumpM1MacTimings () { exit 1 fi plisttojson "$theplist" | { perl -e ' use JSON::PP; my $ioreg = decode_json (<>); @@ -81,4 +109,6 @@ dumpM1MacTimings () { || echo "# perl failed" 1>&2 ; } } if ((dodump)); then dumpM1MacTimings "$1" fi -
joevt revised this gist
Jan 1, 2021 . No changes.There are no files selected for viewing
-
joevt created this gist
Jan 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,84 @@ #!/bin/bash # by joevt Jan 1/2021 dumpM1MacTimings () { local theplist="$1" if [[ -z "$theplist" ]]; then theplist="$(mktemp)" ioreg -alr -k "display-timing-info" > "$theplist" fi local st_size=0 eval "$(stat -s "$theplist")" if ((st_size == 0)); then echo "# Error: display-timing-info not found" 1>&2 exit 1 fi sed -E ' /^'$'\t''*<data>/,/^'$'\t''*<\/data>/ { /^('$'\t''*)<data>(.*)/ { s//\1<string>_data:\2/; h; d; }; /^'$'\t''*<\/data>(.*)/! { s/^'$'\t''+(.*)/\1/; H; d; }; /^'$'\t''*<\/data>(.*)/ { s//:data_<\/string>\1/; H; g; s/\n//g; }; } ' "$theplist" | { plutil -convert json - -o - || echo "# plutil failed" 1>&2 ; } | { perl -e ' use JSON::PP; my $ioreg = decode_json (<>); my $parentname; sub donode { my $node = $_[0]; if ($node->{"IOObjectClass"} eq "AppleCLCD2") { print "\n$parentname:\n"; for my $timingelement (@{$node->{"TimingElements"}}) { printf( "%s%dx%d%s@%.3fHz %.3fkHz %.2fMHz h(%d %d %d %s) v(%d %d %d %s) %s%s%s%s%s\n", ((exists $node->{"DPTimingModeId"}) && $timingelement->{"ID"} eq $node->{"DPTimingModeId"}) ? " -> " : " ", $timingelement->{"HorizontalAttributes"}{"Active"}, $timingelement->{"VerticalAttributes"}{"Active"}, $timingelement->{"IsInterlaced"} ? "i" : "", $timingelement->{"VerticalAttributes"}{"PreciseSyncRate"} / 65536.0, $timingelement->{"HorizontalAttributes"}{"PreciseSyncRate"} / 65536.0, $timingelement->{"HorizontalAttributes"}{"PreciseSyncRate"} * $timingelement->{"HorizontalAttributes"}{"Total"} / 65536000.0, $timingelement->{"HorizontalAttributes"}{"FrontPorch"}, $timingelement->{"HorizontalAttributes"}{"SyncWidth"}, $timingelement->{"HorizontalAttributes"}{"BackPorch"}, $timingelement->{"HorizontalAttributes"}{"SyncPolarity"} ? "+" : "-", $timingelement->{"VerticalAttributes"}{"FrontPorch"}, $timingelement->{"VerticalAttributes"}{"SyncWidth"}, $timingelement->{"VerticalAttributes"}{"BackPorch"}, $timingelement->{"VerticalAttributes"}{"SyncPolarity"} ? "+" : "-", $timingelement->{"IsOverscanned"} ? " (overscan)" : "", $timingelement->{"IsPreferred"} ? " (preferred)" : "", $timingelement->{"IsPromoted"} ? " (promoted)" : "", $timingelement->{"IsSplit"} ? " (tiled)" : "", $timingelement->{"IsVirtual"} ? " (virtual)" : "" ); } } else { $parentname = $node->{"IORegistryEntryName"}; foreach my $childnode (@{$node->{"IORegistryEntryChildren"}}) { donode($childnode); } } } foreach my $node (@{$ioreg}) { donode($node); } ' \ || echo "# perl failed" 1>&2 ; } } dumpM1MacTimings "$1"