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

set netbook resolution + batt for laptop
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Nov 09 21:16:17 2009 +0100 (2009-11-09)
parents 16c27ed1f2c9
children 3c447e4af92c
line source
1 #!/bin/sh
2 # /etc/init.d/hwconf.sh - SliTaz hardware configuration.
3 #
4 # This script configures 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 XARG=""
11 for opt in `cat /proc/cmdline`
12 do
13 case $opt in
14 sound=*)
15 DRIVER=${opt#sound=} ;;
16 xarg=*)
17 XARG="$XARG ${opt#xarg=}" ;;
18 screen=*)
19 SCREEN=${opt#screen=} ;;
20 *)
21 continue ;;
22 esac
23 done
25 # Sound configuration stuff. First check if sound=no and remove all
26 # sound Kernel modules.
27 if [ -n "$DRIVER" ]; then
28 case "$DRIVER" in
29 no)
30 echo -n "Removing all sound kernel modules..."
31 rm -rf /lib/modules/`uname -r`/kernel/sound
32 status
33 echo -n "Removing all sound packages..."
34 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
35 pkg=${i#/var/lib/tazpkg/installed/}
36 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
37 done
38 for i in alsa-lib mhwaveedit asunder libcddb ; do
39 echo 'y' | tazpkg remove $i > /dev/null
40 done
41 status ;;
42 noconf)
43 echo "Sound configuration was disabled from cmdline..." ;;
44 *)
45 if [ -x /usr/sbin/soundconf ]; then
46 echo "Using sound kernel module $DRIVER..."
47 /usr/sbin/soundconf -M $DRIVER
48 fi ;;
49 esac
50 # Sound card may already be detected by PCI-detect.
51 elif [ -d /proc/asound ]; then
52 # Restore sound config for installed system.
53 if [ -s /etc/asound.state ]; then
54 echo -n "Restoring last alsa configuration..."
55 alsactl restore
56 status
57 else
58 /usr/sbin/setmixer
59 fi
60 # Start soundconf to config driver and load module for Live mode
61 # if not yet detected.
62 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
63 else
64 echo "Unable to configure sound card."
65 fi
67 # Screen size config for slim/Xvesa (last config dialog before login).
68 if [ ! -s /etc/X11/screen.conf -a -x /usr/bin/slim ]; then
69 # $HOME is not yet set.
70 HOME=/root
71 if [ -n "$XARG" ]; then
72 # Add an extra argument to xserver_arguments (xarg=-2button)
73 sed -i "s| -screen|$XARG -screen|" /etc/slim.conf
74 fi
75 if [ -n "$SCREEN" ]; then
76 case "$SCREEN" in
77 text)
78 # Disable X.
79 echo -n "Disabling X login manager: slim..."
80 . /etc/rcS.conf
81 RUN_DAEMONS=`echo $RUN_DAEMONS | sed s/' slim'/''/`
82 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
83 status ;;
84 auto)
85 # Auto detect screen resolution.
86 export NEW_SCREEN=`Xvesa -listmodes 2>&1 | grep ^0x | \
87 awk '{ printf "%s %s\n",$2 }' \
88 | sort -nr | grep x[1-2][4-6] | head -n 1`
89 tazx `cat /etc/X11/wm.default` ;;
90 1024x600*|800x480*)
91 set -- $(echo $SCREEN | sed 's/x/ /g')
92 915resolution -l 2>/dev/null | \
93 grep " ${1}x" | awk -v h=$1 -v v=$2 \
94 'END {system("915resolution " $2 " " h " " v)}'
95 # Use specified screen resolution.
96 export NEW_SCREEN=$SCREEN
97 tazx `cat /etc/X11/wm.default` ;;
98 *)
99 # Use specified screen resolution.
100 export NEW_SCREEN=$SCREEN
101 tazx `cat /etc/X11/wm.default` ;;
102 esac
103 else
104 tazx `cat /etc/X11/wm.default`
105 fi
106 fi