slitaz-boot-scripts view etc/init.d/hwconf.sh @ rev 170

hwconf.sh: Add screen=auto option to autodetect screen resolution
author Christophe Lincoln <pankso@slitaz.org>
date Mon Apr 27 15:57:21 2009 +0200 (2009-04-27)
parents 052f4f60ee36
children 75125fb17674
line source
1 #!/bin/sh
2 # /etc/init.d/hwconf.sh - SliTaz hardware configuration.
3 #
4 # This script configure the sound card and screen. Tazhw is used earlier
5 # at boot time to autoconfigure PCI and USB devices.
6 #
7 . /etc/init.d/rc.functions
9 # Parse cmdline args for boot options (See also rcS and bootopts.sh).
10 for opt in `cat /proc/cmdline`
11 do
12 case $opt in
13 sound=*)
14 DRIVER=${opt#sound=} ;;
15 xargs=*)
16 XARGS=${opt#xargs=} ;;
17 screen=*)
18 SCREEN=${opt#screen=} ;;
19 *)
20 continue ;;
21 esac
22 done
24 # Sound configuration stuff. First check if sound=no and remove all
25 # sound Kernel modules.
26 if [ -n "$DRIVER" ]; then
27 case "$DRIVER" in
28 no)
29 echo -n "Removing all sound kernel modules..."
30 rm -rf /lib/modules/`uname -r`/kernel/sound
31 status
32 echo -n "Removing all sound packages..."
33 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
34 pkg=${i#/var/lib/tazpkg/installed/}
35 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
36 done
37 for i in alsa-lib mhwaveedit asunder libcddb ; do
38 echo 'y' | tazpkg remove $i > /dev/null
39 done
40 status ;;
41 noconf)
42 echo "Sound configuration was disabled from cmdline..." ;;
43 *)
44 if [ -x /usr/sbin/soundconf ]; then
45 echo "Using sound kernel module $DRIVER..."
46 /usr/sbin/soundconf -M $DRIVER
47 fi ;;
48 esac
49 # Sound card may already be detected by PCI-detect.
50 elif [ -d /proc/asound ]; then
51 # Restore sound config for installed system.
52 if [ -s /etc/asound.state ]; then
53 echo -n "Restoring last alsa configuration..."
54 alsactl restore
55 status
56 else
57 /usr/sbin/setmixer
58 fi
59 # Start soundconf to config driver and load module for Live mode
60 # if not yet detected.
61 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
62 else
63 echo "Unable to configure sound card."
64 fi
66 # Screen size config for slim/Xvesa (last config dialog before login).
67 if [ ! -s /etc/X11/screen.conf -a -x /usr/bin/slim ]; then
68 # $HOME is not yet set.
69 HOME=/root
70 if [ -n "$XARGS" ]; then
71 # Add an extra argument to xserver_arguments (xarg=-2button)
72 sed -i "s|-screen|$XARG -screen|" /etc/slim.conf
73 fi
74 if [ -n "$SCREEN" ]; then
75 case "$SCREEN" in
76 text)
77 # Disable X.
78 echo -n "Disabling X login manager: slim..."
79 . /etc/rcS.conf
80 RUN_DAEMONS=`echo $RUN_DAEMONS | sed s/' slim'/''/`
81 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
82 status ;;
83 auto)
84 # Auto detect screen resolution.
85 export NEW_SCREEN=`Xvesa -listmodes 2>&1 | grep ^0x | \
86 awk '{ printf "%s %s\n",$2 }' \
87 | sort -nr | grep x[1-2][4-6] | head -n 1`
88 tazx `cat /etc/X11/wm.default` ;;
89 *)
90 # Use specified screen resolution.
91 export NEW_SCREEN=$SCREEN
92 tazx `cat /etc/X11/wm.default` ;;
93 esac
94 else
95 tazx `cat /etc/X11/wm.default`
96 fi
97 fi