#!/bin/sh
# Filename:      samsung_x20
# Purpose:       optimize settings for Samsung X20 laptop
# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2.
# Latest change: Sun May 14 11:55:52 CEST 2006 [mika]
################################################################################

. /etc/grml_colors
. /etc/grml/lsb-functions

case "$1" in
        (start) log_begin_msg "Starting /etc/init.d/samsung_x20"
                log_end_msg $?

                echo -n "${SUBMSG}Setting keycodes for F14 and F15."
                setkeycodes 75 94 && setkeycodes 74 93
                log_end_msg $?

                if [ -x /usr/sbin/915resolution ]
                then
                        echo -n "${SUBMSG}Setting resolution for X window system to 1400x1050."
                        /usr/sbin/915resolution 4d 1400 1050 1>/dev/null
                        log_end_msg $?
                elif [ -x /usr/sbin/855resolution ]
                then
                        echo -n "${SUBMSG}Setting resolution for X window system to 1400x1050."
                        /usr/sbin/855resolution 4d 1400 1050 1>/dev/null
                        log_end_msg $?
                else
                        log_failure_msg "  Error - could not find 915resolution or 855resolution."
                        log_end_msg 1
                fi

                echo -n "${SUBMSG}Loading evdev kernel module."
                modprobe evdev
                log_end_msg $?

                if [ -f /etc/X11/xorg.conf ]
                then
                        log_warning_msg "  /etc/X11/xorg.conf exists already, skipping running grml-x."
                        log_end_msg 0
                else
                        log_begin_msg "${SUBMSG}Creating xorg.conf without starting X."
                        # grml-x -nosync -nostart fluxbox > /dev/null 2>& 1
                        grml-x -nostart fluxbox > /dev/null 2>& 1
                        log_end_msg $?
                fi

                log_begin_msg "Finished running /etc/init.d/samsung_x20"
                log_end_msg $? ;;

        (stop) echo "Stopping samsung_x20 - this won't run anything."
               echo "This script only supports the start and the force-reload option." ;;

        (restart) $0 stop
                sleep 1
                $0 start ;;

        (force-reload) log_begin_msg "Force-reloading samsung_x20 - this will recreate /etc/X11/xorg.conf."
                log_end_msg $?
                echo "${SUBMSG}Creating xorg.conf without starting X."
                echo "${SUBMSG}Force creating xorg.conf without starting X."
                [ -f /etc/X11/xorg.conf ] && mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
                grml-x -nosync -nostart -force fluxbox > /dev/null 2>& 1
                log_end_msg $? ;;

        (*) echo "Usage: $0 {start|stop|restart|force-reload}" >& 2
                exit 1 ;;

esac

exit 0

## END OF FILE #################################################################
