init.d runscript: dual <==> single display boot option

Discussion in general that pertains to Sabayon Linux - Must Pertain to Sabayon Linux

Moderator: Moderators

init.d runscript: dual <==> single display boot option

Postby aether3 » Fri Mar 27, 2009 4:13

Hi guys, some of you might know me (aka aether7) from irc, I usually idle in #sabayon. I thought I would just share a little script with this great community. The script below is a very nice way to choose between a multimonitor setup or a single monitor setup at the bootloader. This will require some configuration on your part if you want to use it as I didn't make it user friendly at least in terms of installation. Although I am fairly certain there is no real risk, DOING THE BELOW IS AT YOUR OWN RISK.

Code: Select all
#!/sbin/runscript
# Jon Carrier
# To be placed in /etc/init.d/
# Run Command: rc-update add xdisplay boot

depend()
{
   need localmount
   before xdm-setup
   before xdm
   before alsasound
}

start()
{

   cmdline_display_mode_exist=$(cat /proc/cmdline | grep "display=")
   display_mode_dual_exist=$(ls /home/aether/conf/xorg/ | grep "xorg.conf.dual")
   display_mode_single_exist=$(ls /home/aether/conf/xorg/ | grep "xorg.conf.single")
   cmdline_display_mode=$(cat /proc/cmdline | awk -Fdisplay= '{print $2}' | awk '{print $1}')
   if [ -n "$cmdline_display_mode_exist" ]; then
      if [ -n "$display_mode_dual_exist" ] && [ -n "$display_mode_single_exist" ]; then
            #Choose the xorg file to be copied over
            if [ "$cmdline_display_mode" == "dual" ]; then
               ebegin "Configuring X display in TwinView mode"
               cp /home/aether/conf/xorg/xorg.conf.dual /etc/X11/xorg.conf
            else
               ebegin "Configuring X display in Standard mode"
               cp /home/aether/conf/xorg/xorg.conf.single /etc/X11/xorg.conf
            fi
         sleep 5
         eend 0
      else
         ebegin "Xorg file missing. Exitting"
         eend 0
      fi
   fi

}


So here is what you will need to do to get this to work.
1. Make a file that contains the above code. I called this file "xdisplay"
2. Make two versions of your xorg.conf file; one for single display and one for dual display configuration. These should be named "xorg.conf.single" and "xorg.conf.dual" respectively. If you don't know how, best read up cause this isn't the topic of discussion.
3. Place these in some logical place on your local disk
4. Edit the file that contains the above code to point to those two files.
I.e. Replace all occurances of this path:
/home/aether/conf/xorg/
with the path where those two xorg.conf files are located
5. Now move this file (xdisplay) to the /etc/init.d/ directory
6. Add this to rc-update list. Use: rc-update add xdisplay boot
7. Open your grub menu in /boot/grub/menu.lst
8. Add two more sabayon sections. Just make two copies of your existing one that you normally boot from.
In one case you add the flag:
display=dual
In the other case you add the flag:
display=single
Technically it doesn't matter what you have after "display=" in this case as it default to single if dual is not satified
9. I suggest you keep your existing section you boot from as the default that way it only bothers copying the xorg files when you need to change modes.

Here is an example of my menu.lst after configuration
Code: Select all
# grub.conf generated by the Sabayon Linux Installer
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,4)
#          kernel /kernel-genkernel real_root=/dev/VolGroup00/LogVol00
#          initrd /initramfs-genkernel
#boot=sda
default=0
timeout=30
splashimage=(hd0,4)/grub/splash.xpm.gz

title Sabayon Linux (genkernel-x86_64-2.6.27-sabayon) (music)
   root (hd0,4)
   kernel /kernel-genkernel-x86_64-2.6.27-sabayon music root=/dev/ram0 ramdisk=8192 real_root=/dev/VolGroup00/LogVol00 dolvm  quiet  init=/linuxrc splash=silent,theme:sabayon CONSOLE=/dev/tty1 vga=0x369 resume=swap:/dev/mapper/VolGroup00-LogVol01
   initrd /initramfs-genkernel-x86_64-2.6.27-sabayon

title Sabayon Linux (genkernel-x86_64-2.6.27-sabayon) (verbose)
        root (hd0,4)
   kernel /kernel-genkernel-x86_64-2.6.27-sabayon root=/dev/ram0 ramdisk=8192 real_root=/dev/VolGroup00/LogVol00 dolvm  quiet  init=/linuxrc splash=verbose,theme:sabayon CONSOLE=/dev/tty1 vga=0x369 resume=swap:/dev/mapper/VolGroup00-LogVol01
   initrd /initramfs-genkernel-x86_64-2.6.27-sabayon

title Sabayon Linux (genkernel-x86_64-2.6.27-sabayon) (verbose) (dual)
        root (hd0,4)
   kernel /kernel-genkernel-x86_64-2.6.27-sabayon display=dual root=/dev/ram0 ramdisk=8192 real_root=/dev/VolGroup00/LogVol00 dolvm  quiet  init=/linuxrc splash=verbose,theme:sabayon CONSOLE=/dev/tty1 vga=0x369 resume=swap:/dev/mapper/VolGroup00-LogVol01
   initrd /initramfs-genkernel-x86_64-2.6.27-sabayon

title Sabayon Linux (genkernel-x86_64-2.6.27-sabayon) (verbose) (single)
        root (hd0,4)
   kernel /kernel-genkernel-x86_64-2.6.27-sabayon display=single root=/dev/ram0 ramdisk=8192 real_root=/dev/VolGroup00/LogVol00 dolvm  quiet  init=/linuxrc splash=verbose,theme:sabayon CONSOLE=/dev/tty1 vga=0x369 resume=swap:/dev/mapper/VolGroup00-LogVol01
   initrd /initramfs-genkernel-x86_64-2.6.27-sabayon

title Sabayon Linux (genkernel-x86_64-2.6.27-sabayon) (safe mode)
   root (hd0,4)
   kernel /kernel-genkernel-x86_64-2.6.27-sabayon root=/dev/ram0 ramdisk=8192 real_root=/dev/VolGroup00/LogVol00 dolvm init=/linuxrc CONSOLE=/dev/tty1 resume=swap:/dev/mapper/VolGroup00-LogVol01 nox acpi=off ide=nodma vga=normal
   initrd /initramfs-genkernel-x86_64-2.6.27-sabayon

title Microsoft Windows Vista Ultimate
   rootnoverify (hd0,2)
   makeactive
   chainloader +1

title Dell Diagnostics
   rootnoverify (hd0,0)
   makeactive
   chainloader +1


Hope this is useful to some. Enjoy 8)
P.S. I am not an expert at init.d runscripts so if I did anything improperly please let me/us know.
aether3
Baby Hen
 
Posts: 3
Joined: Sat Oct 04, 2008 2:33

Re: init.d runscript: dual <==> single display boot option

Postby wolfden » Fri Mar 27, 2009 5:48

can you please add this to the wiki instead if you haven't already. Feel free to post a link in wiki page to this thread - Thanks
wolfden
Sharecropper
 
Posts: 9051
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA

Re: init.d runscript: dual <==> single display boot option

Postby aether3 » Fri Mar 27, 2009 16:22

Will do. I wasn't even thinking about wiki when I posted this, makes more sense there though. Would this be a suited for the graphics section or other section?
aether3
Baby Hen
 
Posts: 3
Joined: Sat Oct 04, 2008 2:33

Re: init.d runscript: dual <==> single display boot option

Postby wolfden » Fri Mar 27, 2009 19:38

either or will work
wolfden
Sharecropper
 
Posts: 9051
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA


Return to Sabayon Linux General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron