Create custom boot profile in Linux

From ezUnix
Jump to: navigation, search
                                    pdf_icon.png Download this article as a single PDF document 

Introduction

I use my laptop primary at work and home where I have two different setups for my monitors.
At work I use two external screens and docking station and at home I use one external screen and the laptop screen.
Sadly it is possible to use only two screens per head so I was not be able to connect 3 screens on at the same time.
And even If I defined three screens in my config I could not use the two externals screens as the laptop screen is always picked as the first one disabling one of the external screens.
Suma sumarum, there was no way to use 2 external screens with the same config as for one external screen and the laptop screen.


Solution

A solution for that is to create custom profiles, chose one at boot and configure the system based on the info passed to the kernel.

Grub config


In my Grub config file - /boot/grub/menu.lst, I give a parameter, a text string to the kernel:

default saved
timeout=30

title=Laptop and one external screen
root (hd0,0)
kernel /boot/my_kernel root=/dev/sda1 rootdelay=5 serverlayout=laptop
initrd /boot/initrd.img

title=Two external screens
root (hd0,0)
kernel /boot/my_kernel root=/dev/sda1 rootdelay=5 serverlayout=2screens
initrd /boot/initrd.img

Custom startup script

In my /etc/rc.local on Debian/Ubuntu ( /etc/conf.d/local.start on Gentoo) I fetch this parameter and link /etc/X11/xorg.conf to my custom Xorg config:


#!/bin/bash
#
# rc.local
#
## Choose correct xorg.conf ##
for arg in $(cat /proc/cmdline);
        do
        echo $arg | grep "serverlayout" > /dev/null 2>&1
        if [ $? == 0 ]
        then
               val=$(echo $arg | cut -d= -f2)
               ### Remove old symlink if exists ###
               if [ -L /etc/X11/xorg.conf ]; then
                       rm /etc/X11/xorg.conf  
               fi

               if [ -f /etc/X11/xorg.conf.$val ]; then
                       ln -s /etc/X11/xorg.conf.$val /etc/X11/xorg.conf
                       ###  Restart login manager - kdm to use correct config ### 
                       /etc/init.d/kdm restart
               fi
        fi
done

exit 0

Custom Xorg configs

And I have my custom Xorg configuration files in /etc/X11/ , one for each option:


-rw-r--r-- 1 root root 5930 Feb 21 20:53 /etc/X11/xorg.conf.2screens
-rw-r--r-- 1 root root 5507 Feb 22 09:16 /etc/X11/xorg.conf.laptop
lrwxrwxrwx 1 root root 14 Feb 22 09:17 /etc/X11/xorg.conf -> xorg.conf.2screens 

Here you can see a symlink from xorg.conf to xorg.conf.2screens


That's all folks.
Marcin


<comments />

inikecttraurnk said ...
19:34, 9 March 2011 (CET)
Hello.

The interesting name of a site - www.ezunix.org, interesting this here is very good.

I spent 3 hours searching in the network, until find your forum!

Mogo said ...

<comment date="2012-04-16T02:19:10Z" name="Mogo"> Si necesitas barorr completamente los datos que almacena wallet en N9, necesitas barorr dos archivos:/home/user/qtwallet.db.sqlite/home/user/.config/nowheremanmail/qtWallet.confEsto lo puedes hacer descarge1ndote algun explorador de archivos disponible en OVI store. </comment>

lele said ...

<comment date="2012-04-16T10:53:31Z" name="lele"> A couple deautps to this saga. AutoReleaseButtons has been added to xorg's input class. For a fix that will survive dist upgrades, do the following:sudo mkdir /etc/X11/xorg.conf.d/cd /etc/X11/xorg.conf.d/sudo nano 910-rat.conf# add the following to the fileSection InputClass Identifier R.A.T. MatchProduct R.A.T.7|R.A.T.9 MatchDevicePath /dev/input/event* Option Buttons 17 Option ButtonMapping 1 2 3 4 5 0 0 8 9 7 6 12 0 0 0 16 17 Option AutoReleaseButtons 13 14 15 Option ZAxisMapping 4 5 6 7 EndSection[] </comment>

Ahmed said ...

<comment date="2012-04-17T03:44:19Z" name="Ahmed"> I would like to see this xorg.conf. The above link appears to be obrken.I have this same tv and I am trying to optimize the xorg.conf for my new ion mythtv frontend. Do you still have this file?Thanks! </comment>

Isabel said ...

<comment date="2012-04-17T08:12:32Z" name="Isabel"> For debian seeuqze and RAT7 Contagion:Section InputDevice Identifier Saitek Cyborg R.A.T.7 Contagion Driver mouse Option Protocol auto Option Buttons 17 Option ButtonMapping 1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 16 17 Option ZAxisMapping 4 5 6 7 Option YAxisMapping 10 11 EndSectionBut horizontal scrolling still dont working.[] </comment>

Florenciaa said ...

<comment date="2012-04-19T02:26:55Z" name="Florenciaa"> I'll be very interested to hear if you do fix it bucaese buying a tablet is high on my shopping list but I've always been put off by possible lack of GIMP support.Good luck! </comment>

Cleophace said ...

<comment date="2012-04-19T02:54:05Z" name="Cleophace"> There's drivers for all of my hawrrade this thing's had support for everything since Feisty. As of Gutsy, the resolution is right out of the box as well. It's a Gateway MX 6920. Specs as follows:00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 02)00:1c.1 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 2 (rev 02)00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 02)00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 02)00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 02)00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 02)00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 02)00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02)00:1f.2 SATA controller: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA AHCI Controller (rev 02)00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 02)02:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8038 PCI-E Fast Ethernet Controller (rev 14)03:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)04:09.0 CardBus bridge: Texas Instruments PCIxx12 Cardbus Controller04:09.1 FireWire (IEEE 1394): Texas Instruments PCIxx12 OHCI Compliant IEEE 1394 Host Controller04:09.2 Mass storage controller: Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD) </comment>

Ester said ...

<comment date="2012-04-19T04:57:13Z" name="Ester"> this change in the Xorg.conf makes my W510 to hang while boinotg the only thing that helps is to use the brightness-buttons while being in the grup menu. hope this gets fixed soon </comment>