home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / xresprobe / ddcprobe.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2007-03-17  |  2.5 KB  |  74 lines

  1. #!/bin/sh
  2. # Copyright (C) 2004 Canonical Ltd.
  3. # Author: Daniel Stone <daniel.stone@ubuntu.com>
  4. #  This program is free software; you can redistribute it and/or modify
  5. #  it under the terms of the GNU General Public License as published by
  6. #  the Free Software Foundation; version 2 of the License.
  7. #
  8. #  This program is distributed in the hope that it will be useful,
  9. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. #  GNU General Public License for more details.
  12. #
  13. #  You should have received a copy of the GNU General Public License with
  14. #  the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL-2;
  15. #  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  16. #  Suite 330, Boston, MA  02111-1307  USA
  17. #
  18. # On Debian systems, the complete text of the GNU General Public
  19. # License, version 2, can be found in /usr/share/common-licenses/GPL-2.
  20.  
  21. BLACKLISTMODES="2288x1430"
  22.  
  23. if [ -n "$1" ]; then
  24.   DDCPROBE="$(cat $1)"
  25. else
  26.   DDCPROBE="$(ddcprobe 2>/dev/null)"
  27. fi
  28. if [ "$?" = "1" ]; then
  29.   exit 1
  30. fi
  31. if (echo "$DDCPROBE" | egrep "(edidfail|ddcfail)" >/dev/null 2>&1); then
  32.   exit 0
  33. fi
  34.  
  35. if (echo "$DDCPROBE" | egrep "^input: .*digital"); then
  36.   SCREENTYPE="lcd"
  37. else
  38.   SCREENTYPE="crt"
  39. fi
  40.  
  41. TIMINGS="$(echo "$DDCPROBE" | egrep '^[cd]*timing:' | \
  42.      sed -e 's/^[cd]*timing: \([^x]*\)x\([^ @$]*\).*$/\1x\2/;' | \
  43.      sort -nr | egrep -v "$BLACKLISTMODES")"
  44.  
  45. # highest in this case means 'highest resolution', and we want to demote it
  46. # to the least-preferred resolution; it will usually be completely unviewable
  47.  
  48. if [ -n "$XRESPROBE_DEBUG" ]; then
  49.    echo "raw timings - $(echo "$TIMINGS" | xargs echo)" >&2
  50. fi
  51.  
  52. NTIMINGS="$(echo "$TIMINGS" | wc -l)"
  53. HIGHEST="$(echo "$TIMINGS" | head -n 1)"
  54. OUTTIMINGS="$(echo "$TIMINGS" | tail -n "$(($NTIMINGS-1))")"
  55. MONITORNAME="$(echo "$DDCPROBE" | egrep '^monitorname:' | sed -e 's/^monitorname: //;')"
  56. MONITORRANGE="$(echo "$DDCPROBE" | egrep '^monitorrange:' | sed -e 's/^monitorrange: //;' -e 's/\,//;')"
  57. TIMINGS="$(echo "$TIMINGS" | sort -rnu -tx -k1,1nr -k2,2nr)"
  58. OUTTIMINGS="$(echo "$OUTTIMINGS" | sort -rnu -tx -k1,1nr -k2,2nr)"
  59.  
  60. if [ "$SCREENTYPE" = "lcd" ]; then
  61.   echo "res: $(echo $TIMINGS | xargs echo)"
  62.   echo "disptype: lcd"
  63. else
  64.   if [ "$NTIMINGS" -gt "1" ]; then
  65.     echo "res: $(echo $OUTTIMINGS | xargs echo)"
  66.   else
  67.     echo "res: $(echo $HIGHEST | xargs echo)"
  68.   fi
  69.   echo "disptype: crt"
  70. fi
  71. echo "name: $MONITORNAME"
  72. echo "freq: $MONITORRANGE"
  73.