Пиша един скрип за генериране на файла XF86Config и настройка на мишката (/dev/mouse). Имам един проблем - променям една променлива и след промяната се оказва, че променливата не се е променила. Ето част от кода:
=============== <част от кода> ====================== s_flag="s5" # С тази променлива имам проблем... if [ -r "$XF86Config_new_location" ]; then cat "$XF86Config_new_location" | while read LINE ; do * * * * тука стават разни неща с променливата s_flag, но при всички случаи й се присвоява стойност различна от s5 * * * * # контролно печатане на променливата echo "Променливата s_flag е: $s_flag" # тук печата каквото се очаква done else echo "Грешка при четенето на файла $XF86Config_new_location" fi # контролно печатане на променливата echo "Променливата s_flag е: $s_flag" # Тази променлива всеки път е s5. =============== </част от кода> ====================== Ето го и целия код: #!/bin/sh echo "Стартира се rc.hwconfig..." date IDENT_MONITOR="Auto_Configured_Monitor" IDENT_CARD="Auto_Configured_Card" IDENT_SCREEN="Auto_Configured_Screen" XF86Config_location="/etc/X11/XF86Config" XF86Config_new_location="/root/XF86Config.new" rm -f $XF86Config_new_location # Изтриване на стария /root/XF86Config.new, на негово място ще се запише нов. ERR_MSG=`/usr/X11R6/bin/XFree86 -configure 2>&1` if [ ! $? = 0 ]; then echo "Грешка при изпълнение на XFree86:" echo $ERR_MSG # exit echo "Въпреки това скрипта продължава да се изпълнява..." fi rm -f $XF86Config_location # Изтриване на стария XF86Config, на негово място ще се запише нов. cat > "$XF86Config_location" << EOF # Този файл е генериран автоматично # ********************************************************************** # Вижте man страницата XF86Config(4/5) за информация, относно структурата # на този файл. # ********************************************************************** # ********************************************************************** # Module section -- this section is used to specify # which dynamically loadable modules to load. # ********************************************************************** # Section "Module" # This loads the DBE extension module. Load "dbe" # Double buffer extension # This loads the miscellaneous extensions module, and disables # initialisation of the XFree86-DGA extension within that module. SubSection "extmod" Option "omit xfree86-dga" # don't initialise the DGA extension EndSubSection # This loads the font modules # Load "type1" Load "freetype" # Load "speedo" # This loads the GLX module Load "glx" EndSection # ********************************************************************** # Files section. This allows default font and rgb paths to be set # ********************************************************************** Section "Files" # The location of the RGB database. Note, this is the name of the # file minus the extension (like ".txt" or ".db"). There is normally # no need to change the default. RgbPath "/usr/X11R6/lib/X11/rgb" # Multiple FontPath entries are allowed (which are concatenated together), # as well as specifying multiple comma-separated entries in one FontPath # command (or a combination of both methods) # # If you don't have a floating point coprocessor and emacs, Mosaic or other # programs take long to start up, try moving the Type1 and Speedo directory # to the end of this list (or comment them out). # FontPath "/usr/X11R6/lib/X11/fonts/bg/bolkhov/cp1251/misc" FontPath "/usr/X11R6/lib/X11/fonts/bg/bolkhov/cp1251/75dpi" FontPath "/usr/X11R6/lib/X11/fonts/bg/cronyx/cp1251/100dpi" FontPath "/usr/X11R6/lib/X11/fonts/bg/misc" FontPath "/usr/X11R6/lib/X11/fonts/misc/" # ModulePath can be used to set a search path for the X server modules. # The default path is shown here. # ModulePath "/usr/X11R6/lib/modules" EndSection # ********************************************************************** # Server flags section. # ********************************************************************** Section "ServerFlags" Option "AllowMouseOpenFail" "true" # Uncomment this to cause a core dump at the spot where a signal is # received. This may leave the console in an unusable state, but may # provide a better stack trace in the core dump to aid in debugging # Option "NoTrapSignals" # Uncomment this to disable the <Crtl><Alt><Fn> VT switch sequence # (where n is 1 through 12). This allows clients to receive these key # events. # Option "DontVTSwitch" # Uncomment this to disable the <Crtl><Alt><BS> server abort sequence # This allows clients to receive this key event. # Option "DontZap" # Uncomment this to disable the <Crtl><Alt><KP_+>/<KP_-> mode switching # sequences. This allows clients to receive these key events. # Option "DontZoom" # Uncomment this to disable tuning with the xvidtune client. With # it the client can still run and fetch card and monitor attributes, # but it will not be allowed to change them. If it tries it will # receive a protocol error. # Option "DisableVidModeExtension" # Uncomment this to enable the use of a non-local xvidtune client. # Option "AllowNonLocalXvidtune" # Uncomment this to disable dynamically modifying the input device # (mouse and keyboard) settings. # Option "DisableModInDev" # Uncomment this to enable the use of a non-local client to # change the keyboard or mouse settings (currently only xset). # Option "AllowNonLocalModInDev" # Set the basic blanking screen saver timeout. # Option "blank time" "10" # 10 minutes # Set the DPMS timeouts. These are set here because they are global # rather than screen-specific. These settings alone don't enable DPMS. # It is enabled per-screen (or per-monitor), and even then only when # the driver supports it. # Option "standby time" "20" # Option "suspend time" "30" # Option "off time" "60" # On some platform the server needs to estimate the sizes of PCI # memory and pio ranges. This is done by assuming that PCI ranges # don't overlap. Some broken BIOSes tend to set ranges of inactive # devices wrong. Here one can adjust how aggressive the assumptions # should be. Default is 0. # Option "EstimateSizesAggresively" "0" EndSection # ********************************************************************** # Input devices # ********************************************************************** # ********************************************************************** # Core keyboard's InputDevice section # ********************************************************************** Section "InputDevice" Identifier "Keyboard1" Driver "Keyboard" # For most OSs the protocol can be omitted (it defaults to "Standard"). # When using XQUEUE (only for SVR3 and SVR4, but not Solaris), # uncomment the following line. # Option "Protocol" "Xqueue" # Set the keyboard auto repeat parameters. Not all platforms implement # this. # Option "AutoRepeat" "500 5" # Specifiy which keyboard LEDs can be user-controlled (eg, with xset(1)). # Option "Xleds" "1 2 3" # To disable the XKEYBOARD extension, uncomment XkbDisable. # Option "XkbDisable" # To customise the XKB settings to suit your keyboard, modify the # lines below (which are the defaults). For example, for a European # keyboard, you will probably want to use one of: # # Option "XkbModel" "pc102" # Option "XkbModel" "pc105" # # If you have a Microsoft Natural keyboard, you can use: # # Option "XkbModel" "microsoft" # # If you have a US "windows" keyboard you will want: # # Option "XkbModel" "pc104" # # Then to change the language, change the Layout setting. # For example, a german layout can be obtained with: # # Option "XkbLayout" "de" # # or: # # Option "XkbLayout" "de" # Option "XkbVariant" "nodeadkeys" # # If you'd like to switch the positions of your capslock and # control keys, use: # # Option "XkbOptions" "ctrl:swapcaps" # These are the default XKB settings for XFree86 # # Option "XkbRules" "xfree86" # Option "XkbModel" "pc101" # Option "XkbLayout" "us" # Option "XkbVariant" "" # Option "XkbOptions" "" # Option "XkbLayout" "us,bg(phonetic),bg" Option "XkbLayout" "us,bg(phonetic)" Option "XkbOptions" "grp:ctrl_shift_toggle" EndSection # ********************************************************************** # Core Pointer's InputDevice section # ********************************************************************** Section "InputDevice" # Identifier and driver Identifier "Serial Mouse With Wheel" Driver "mouse" Option "ZAxisMapping" "4 5" # On platforms where PnP mouse detection is supported the following # protocol setting can be used when using a newer PnP mouse: # Option "Protocol" "Auto" Option "Protocol" "intellimouse" # The available mouse protocols types that you can set below are: # Auto BusMouse GlidePoint GlidePointPS/2 IntelliMouse IMPS/2 # Logitech Microsoft MMHitTab MMSeries Mouseman MouseManPlusPS/2 # MouseSystems NetMousePS/2 NetScrollPS/2 OSMouse PS/2 SysMouse # ThinkingMouse ThinkingMousePS/2 Xqueue # Option "Protocol" "PS/2" # The mouse device. The device is normally set to /dev/mouse, # which is usually a symbolic link to the real device. Option "Device" "/dev/mouse" # Option "Device" "/dev/psaux" # Option "Device" "/dev/ttyS0" # Option "Device" "/dev/ttyS1" # When using XQUEUE, comment out the above two lines, and uncomment # the following line. # Option "Protocol" "Xqueue" # Baudrate and SampleRate are only for some Logitech mice. In # almost every case these lines should be omitted. # Option "BaudRate" "9600" # Option "SampleRate" "150" # Emulate3Buttons is an option for 2-button Microsoft mice # Emulate3Timeout is the timeout in milliseconds (default is 50ms) # Option "Emulate3Buttons" # Option "Emulate3Timeout" "50" # ChordMiddle is an option for some 3-button Logitech mice # Option "ChordMiddle" EndSection Section "InputDevice" Identifier "Serial Mouse" Driver "mouse" Option "Protocol" "Microsoft" Option "Device" "/dev/ttyS0" Option "Emulate3Buttons" "true" Option "Emulate3Timeout" "70" Option "SendCoreEvents" "true" EndSection Section "InputDevice" Identifier "PS/2 Mouse" Driver "mouse" Option "Protocol" "PS/2" Option "Device" "/dev/psaux" Option "Emulate3Buttons" "true" Option "Emulate3Timeout" "70" Option "SendCoreEvents" "true" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" Identifier "USB Mouse" Driver "mouse" Option "Device" "/dev/input/mice" Option "SendCoreEvents" "true" Option "Protocol" "IMPS/2" Option "ZAxisMapping" "4 5" Option "Buttons" "5" EndSection EOF cat >> "$XF86Config_location" << EOF # ********************************************************************** # Graphics device section # ********************************************************************** EOF s_flag="s5" # С тази променлива имам проблем... if [ -r "$XF86Config_new_location" ]; then cat "$XF86Config_new_location" | while read LINE ; do if echo $LINE | grep -i Section | grep -i \"Device\" 1> /dev/null ; then if [ "$s_flag" = "s2" ] ; then echo "Грешка: Section \"Device\" се среща два пъти" else s_flag="s1" fi fi if [ "$s_flag" = "s1" ]; then if echo $LINE | grep -i Identifier 1> /dev/null ; then echo "Identifier \"$IDENT_CARD\"" >> "$XF86Config_location" else echo "$LINE" >> "$XF86Config_location" fi fi if echo $LINE | grep -i EndSection 1> /dev/null ; then if [ "$s_flag" = "s1" ]; then s_flag="s2" fi fi # контролно печатане на променливата echo "Променливата s_flag е: $s_flag" # тук печата каквото се очаква done else echo "Грешка при четенето на файла $XF86Config_new_location" fi # контролно печатане на променливата echo "Променливата s_flag е: $s_flag" # Тази променлива всеки път е s5. if [ "$s_flag" == "s5" ]; then cat >> "$XF86Config_location" << EOF # Не беше намерен подходящ драйвер за видеокартата. # Ще се използва VESA Framebuffer. # Това е драйвер, който работи с почти всички видеокарти. # !!!!!!!!!!!!!!!!!!!!!!!!!! проблема е, че това трябва да го има само ако # !!!!!!!!!!!!!!!!!!!!!!!!!! има някаква грешка със XFree86 -configure Section "Device" Identifier "VESA Framebuffer" Driver "vesa" #VideoRam 4096 # Insert Clocks lines here if appropriate EndSection EOF fi cat >> "$XF86Config_location" << EOF # ********************************************************************** # Monitor section # ********************************************************************** EOF /bin/ddcxinfo-knoppix -monitor | while read LINE ; do if echo $LINE | grep -i Identifier 1> /dev/null ; then echo " Identifier \"$IDENT_MONITOR\"" >> "$XF86Config_location" else echo "$LINE" >> "$XF86Config_location" fi done cat >> "$XF86Config_location" << EOF # ********************************************************************** # Screen sections # ********************************************************************** EOF LINE=`/bin/ddcxinfo-knoppix -modes` echo "Section \"Screen\"" >> "$XF86Config_location" echo " Identifier \"$IDENT_SCREEN\"" >> "$XF86Config_location" echo " Device \"$IDENT_CARD\"" >> "$XF86Config_location" echo " Monitor \"$IDENT_MONITOR\"" >> "$XF86Config_location" echo "" >> "$XF86Config_location" echo "# If your card can handle it, a higher default color depth (like 24 or 32)" >> "$XF86Config_location" echo "# is highly recommended." >> "$XF86Config_location" echo "" >> "$XF86Config_location" echo "# DefaultDepth 8" >> "$XF86Config_location" echo "# DefaultDepth 16" >> "$XF86Config_location" echo " DefaultDepth 24" >> "$XF86Config_location" echo "# DefaultDepth 32" >> "$XF86Config_location" echo "" >> "$XF86Config_location" echo " Subsection \"Display\"" >> "$XF86Config_location" echo " Depth 8" >> "$XF86Config_location" echo " $LINE" >> "$XF86Config_location" echo " EndSubsection" >> "$XF86Config_location" echo " Subsection \"Display\"" >> "$XF86Config_location" echo " Depth 16" >> "$XF86Config_location" echo " $LINE" >> "$XF86Config_location" echo " EndSubsection" >> "$XF86Config_location" echo " Subsection \"Display\"" >> "$XF86Config_location" echo " Depth 24" >> "$XF86Config_location" echo " $LINE" >> "$XF86Config_location" echo " EndSubsection" >> "$XF86Config_location" echo " Subsection \"Display\"" >> "$XF86Config_location" echo " Depth 32" >> "$XF86Config_location" echo " $LINE" >> "$XF86Config_location" echo " EndSubsection" >> "$XF86Config_location" echo "" >> "$XF86Config_location" echo "EndSection" >> "$XF86Config_location" cat >> "$XF86Config_location" << EOF # ********************************************************************** # ServerLayout sections. # ********************************************************************** EOF echo -e "Section \"ServerLayout\"\n" >> "$XF86Config_location" echo " Identifier \"Auto_Configured_Layout\"" >> "$XF86Config_location" echo " Screen \"Auto_Configured_Screen\"" >> "$XF86Config_location" echo -e " InputDevice \"Keyboard1\" \"CoreKeyboard\"\n" >> "$XF86Config_location" echo "Настройка на мишката..." if [ -r /proc/bus/usb/devices -a "`cat /proc/bus/usb/devices 2>/dev/null | grep -i mouse`" != "" ]; then echo " InputDevice \"USB Mouse\" \"CorePointer\"" >> "$XF86Config_location" ln -sf /dev/input/mice /dev/mouse elif [ -r /proc/interrupts -a "`cat /proc/interrupts | grep -i 'PS/2 Mouse'`" != "" ]; then echo " InputDevice \"PS/2 Mouse\" \"CorePointer\"" >> "$XF86Config_location" ln -sf /dev/psaux /dev/mouse else echo "Предполага се, че имате серийна мишка с колелце, вързана към COM1 (/dev/ttyS0)" echo " InputDevice \"Serial Mouse With Wheel\" \"CorePointer\"" >> "$XF86Config_location" #echo " InputDevice \"Serial Mouse\" \"CorePointer\"" >> "$XF86Config_location" ln -sf /dev/ttyS0 /dev/mouse fi echo -e "\nEndSection" >> "$XF86Config_location" rm -f $XF86Config_new_location # Изтриване на стария /root/XF86Config.new date echo "...изпълнението на rc.hwconfig приключи." ============================================================================ A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers). http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html ============================================================================