home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / bin / y2xfinetune < prev    next >
Encoding:
Text File  |  2000-03-30  |  2.2 KB  |  124 lines

  1. #!/bin/bash
  2. # Copyright (c) 1996 S.u.S.E. GmbH Fuerth, Germany.  All rights reserved.
  3. #
  4. # Author: Marcus Schaefer <ms@suse.de>, 1999
  5. #
  6. # X startup script   
  7. # Usage:  y2xfinetune XSERVER config-file
  8. # XSERVER is the name of a binary relative to /usr/X11R6/bin/
  9. #
  10. # Exit code:
  11. # 0: xfine has run successful. The user selected "Save settings"
  12. # 1: xfine has run successful, but the user canceled.
  13. # 2: Wrong arguments or not root, bug from caller
  14. # 3: xfine failed for some reason
  15. #
  16.  
  17. # make sure that X11 binaries are found
  18. PATH=$PATH:/usr/X11R6/bin
  19.  
  20. XSERVER=$1
  21. CONFIG=$2
  22. LANG=$3
  23. XSERVER_PATH=/usr/X11R6/bin/$XSERVER
  24.  
  25. if [ -z "$LANG" ];then
  26. LANG="en"
  27. fi
  28.  
  29. # are you root ;)
  30. # ---------------
  31. if [ ! $UID = "0" ];then
  32.  echo "$0: only root can do this... abort" 
  33.  exit 2
  34. fi
  35.  
  36.  
  37. # test parameters
  38. # -----------------------
  39.  
  40. if [ -z "$XSERVER" ];then
  41.  echo "$0: no server file specified... abort"
  42.  exit 2
  43. fi
  44. if [ ! -f "$XSERVER_PATH" ];then
  45.  echo "$0: server $XSERVER does not exist... abort"
  46.  exit 2
  47. fi
  48.  
  49. if [ -z "$CONFIG" ];then
  50.  echo "$0: no config file specified... abort"
  51.  exit 2
  52. fi
  53. if [ ! -f "$CONFIG" ];then
  54.  echo "$0: config $CONFIG does not exist... abort"
  55.  exit 2
  56. fi
  57.  
  58.  
  59. # Getting Display 
  60. #-----------------
  61. if [ -z "$DISPLAY" ]; then
  62.  export DISPLAY=:0
  63.  DISPNUM=0
  64. else
  65.  DISPNUM=${DISPNUM##*:}
  66.  DISPNUM=${DISPNUM%%.*}
  67.  DISPNUM=$(( DISPNUM + 1 ))
  68. fi
  69. export DISPLAY=:$DISPNUM
  70.  
  71. rm -f /tmp/.X11-unix/X$DISPNUM
  72. $XSERVER_PATH -xf86config $CONFIG $DISPLAY &
  73. SPID=$!
  74.  
  75. # wait until Server is up 
  76. #-------------------------
  77. sleep 1
  78. until [ -S /tmp/.X11-unix/X$DISPNUM ]
  79. do
  80.   sleep 1
  81. done
  82.  
  83. # run some tiny xterms as corner markers
  84. # set blue background
  85. # run xfine
  86. # ---------
  87.  
  88. xterm -geometry 1x1-0-0 -bg grey -fg grey &
  89. XPID1=$!
  90. xterm -geometry 1x1-0+0 -bg grey -fg grey &
  91. XPID2=$!
  92. xterm -geometry 1x1+0-0 -bg grey -fg grey &
  93. XPID3=$!
  94. xterm -geometry 1x1+0+0 -bg grey -fg grey &
  95. XPID4=$!
  96. xsetroot -solid darkslateblue &
  97. xsetroot -cursor_name top_left_arrow &
  98. xfine -l $LANG -f $CONFIG
  99.  
  100. XRET=$?
  101. kill $XPID1
  102. kill $XPID2
  103. kill $XPID3
  104. kill $XPID4
  105. kill $SPID
  106. case $XRET in
  107.  1 )
  108.    # User cancelled
  109.    cp "$CONFIG" /etc/XF86Config.pre
  110.    rm -rf "$CONFIG"
  111.    exit 1
  112.    ;;
  113.  
  114.  3 )
  115.    # User saved and is content
  116.    exit 0
  117.    ;;
  118.  
  119.  * )
  120.    exit 3
  121.    ;;
  122. esac
  123.