Gentoo installation on Sony VAIO VGN A197vp laptop

This step-by-step guide explains how to get a full-featured and bleeding-edge Gentoo system running.

Laptop specifications

  • screen size : 17” (16/10)
  • nominal resolution : 1920*1200
  • cpu : Pentium-m 735, 1700MHz
  • memory : 512Mo
  • internal wifi controller : Intel Centrino
  • dvd-writer
  • bluetooth

Enabled features summary

  • wpa-compliant wifi via wpa_supplicant (writing in progress).
  • cpu frequency scalability via governor/cpufreqd
  • Softkeys
  • Screen contrast
  • dvd-writer

Features unchecked

  • bluetooth

installing Gentoo stage3

The current version of Gentoo is 2006.1 (08-30-2006), informations on this release can be found here. For short, it comes with GCC-4.1, Glibc 2.4, Gentoo’s baselayout 1.12.1 etc.
There is 2 way to install a stage3 : the minimal-CD or the LiveCD. Simply choose the one that fit your preferences. LiveCD may seems to be easier because it purpose a Gnome-based interface and does not requiere a network connection (never tried). You can freely grab a copy on one of the mirrors.
To complete this step, just follow the instruction of the Gentoo x86 handbook with the special advices provided on this page.

  • network : no problem with DHCP.
  • Preparing the disks :

fdisk : Don’t forget to made a partition bootable (fdisk>a) and to set the swap with the good Id (t=82).

mke2fs /dev/hda1
mkreiserfs /dev/hda3
mkswap /dev/hda2
  • mounts : nc.
  • install a stage from internet (minimal CD) :
cd /mnt/gentoo
links ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/releases/x86/2006.1/stages/

and d on stage3-i686-2006.1.tar.bz2.
Extract it in /mnt/gentoo/ :

tar xvjpf stage3-i686-2006.1.tar.bz2
  • Install portage :

Download the snapshot :

links ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/snapshots/

and d on portage-latest.tar.bz2.
Extract the snapshot in the right place (*/usr/portage*) :

tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr
  • Configure the compilation options in /etc/make.conf :FIXME opengl flag to add.

You can download this file here → :linux:make.conf.

# These settings were set by the catalyst build script that automatically built this stage
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-O2 -march=pentium-m -mmmx -msse -msse2 -pipe"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
USE="aac acpi alsa asf audiofile avi bash-completion bzip2 cdr cpudetection crypt cups custom-cflags divx dri dvd dvdr dvdread ffmpeg foomaticdb gif glut gps gtk gtk2 ieee1394 jpeg latex ldap lm_sensors matroska mime mono mmx mmxext mozilla mp3 mpeg nptl nptlonly ogg oggvorbis     opengl pcmcia pdf png python readline real sndfile sockets ssl sse sse2 tetex tga usb vidix wifi win32codecs X xine xmms xvid xlockrc"
ACCEPT_KEYWORDS="~x86"
INPUT_DEVICES="keyboard mouse"
VIDEO_CARDS="radeon fglrx"
GENTOO_MIRRORS="ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/ "
  • Chrooting :

1. copy the DNS in the new env :

cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

2. mount /proc and /dev :

mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev

3. Enter the new env :

chroot /mnt/gentoo /bin/bash
env-update
>> Regenerating /etc/ld.so.cache...
source /etc/profile
  • Update portage tree :
emerge --sync
  • Glibc locales :
nano -w /etc/locale.gen

Set the locales you need and update with :

locale-gen
  • Set localtime :
cp /usr/share/zoneinfo/Europe/Paris /etc/localtime
  • Get the Kernel sources :
USE="-doc symlink" emerge gentoo-sources

Compile the kernel

cd /usr/src/linux
make menuconfig

Processor type and feature 
   processor family : pentium-M
   
Power management options
 [*]ACPI :
      CONFIG_ACPI=y
      CONFIG_ACPI_AC=y
      CONFIG_ACPI_BATTERY=y
      CONFIG_ACPI_BUTTON=y
      CONFIG_ACPI_VIDEO=y
      CONFIG_ACPI_HOTKEY=y
      CONFIG_ACPI_FAN=y
      CONFIG_ACPI_PROCESSOR=y
      CONFIG_ACPI_THERMAL=y
     
 [*]APM :
     (ALL except first) 
    [ ] Ignore USER SUSPEND
 [*]CPU freq scaling :
        Default CPU freq governor (userspace)
   <*> perf, etc (all policies)
   <*> intel enhanced SpeedStep
     [*] ACPI...
     [*] tables...

Networking
  Don't select wifi here !

Device Drivers
  ## not sure for this ##
  [*] Ethernet 10/100
    <*> REALTEK RTL-8139 C+ 
    <*> REALTEK RTL-8129/8130/8139      
    [*] use PIO
  ## in lsmod at boot !!!##
  [*] Ethernet 1000
   <*> Intel PRO/1000

Don't forget in USB human interface.

#
# ATA/ATAPI/MFM/RLL support
#
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y

#
# Please see Documentation/ide.txt for help/info on IDE drives
#
# CONFIG_BLK_DEV_IDE_SATA is not set
# CONFIG_BLK_DEV_HD_IDE is not set
CONFIG_BLK_DEV_IDEDISK=y
# CONFIG_IDEDISK_MULTI_MODE is not set
CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set

#
# IDE chipset support/bugfixes
#
CONFIG_IDE_GENERIC=y
CONFIG_BLK_DEV_CMD640=y
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
CONFIG_BLK_DEV_IDEPCI=y
CONFIG_IDEPCI_SHARE_IRQ=y
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_BLK_DEV_GENERIC=y
# CONFIG_BLK_DEV_OPTI621 is not set
# CONFIG_BLK_DEV_RZ1000 is not set
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
CONFIG_IDEDMA_PCI_AUTO=y
# CONFIG_IDEDMA_ONLYDISK is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_BLK_DEV_ALI15X3 is not set
# CONFIG_BLK_DEV_AMD74XX is not set
# CONFIG_BLK_DEV_ATIIXP is not set
# CONFIG_BLK_DEV_CMD64X is not set
# CONFIG_BLK_DEV_TRIFLEX is not set
# CONFIG_BLK_DEV_CY82C693 is not set
# CONFIG_BLK_DEV_CS5520 is not set
# CONFIG_BLK_DEV_CS5530 is not set
# CONFIG_BLK_DEV_CS5535 is not set
# CONFIG_BLK_DEV_HPT34X is not set
# CONFIG_BLK_DEV_HPT366 is not set
# CONFIG_BLK_DEV_SC1200 is not set
CONFIG_BLK_DEV_PIIX=y
# CONFIG_BLK_DEV_IT821X is not set
# CONFIG_BLK_DEV_NS87415 is not set
# CONFIG_BLK_DEV_PDC202XX_OLD is not set
# CONFIG_BLK_DEV_PDC202XX_NEW is not set
# CONFIG_BLK_DEV_SVWKS is not set
# CONFIG_BLK_DEV_SIIMAGE is not set
# CONFIG_BLK_DEV_SIS5513 is not set
# CONFIG_BLK_DEV_SLC90E66 is not set
# CONFIG_BLK_DEV_TRM290 is not set
CONFIG_BLK_DEV_VIA82CXXX=y
# CONFIG_IDE_ARM is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_IVB is not set
CONFIG_IDEDMA_AUTO=y
# CONFIG_BLK_DEV_HD is not set




[*] Wireless LAN (non-hamradio)
  Select nothing !!!

Input device support : 

   change resolution to 1920*1200

Character devices
 <*> agpart
  <*>intel
 [] DRM

Devices drives -> I2C support :
  I2C Hardware bus support 
   <*> intel 82801
  Charactere device:
   <*> Sony vaio programmable I/O controller


 --- USB Input Devices
<*> USB Human Interface Device (full HID) support
[*]   HID input layer support (NEW)




Cryptographic options

CONFIG_CRYPTO=y
# CONFIG_CRYPTO_HMAC is not set
# CONFIG_CRYPTO_NULL is not set
# CONFIG_CRYPTO_MD4 is not set
CONFIG_CRYPTO_MD5=y
# CONFIG_CRYPTO_SHA1 is not set
# CONFIG_CRYPTO_SHA256 is not set
# CONFIG_CRYPTO_SHA512 is not set
# CONFIG_CRYPTO_WP512 is not set
# CONFIG_CRYPTO_TGR192 is not set
# CONFIG_CRYPTO_DES is not set
# CONFIG_CRYPTO_BLOWFISH is not set
# CONFIG_CRYPTO_TWOFISH is not set
# CONFIG_CRYPTO_SERPENT is not set
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_AES_586=y
# CONFIG_CRYPTO_CAST5 is not set
# CONFIG_CRYPTO_CAST6 is not set
# CONFIG_CRYPTO_TEA is not set
CONFIG_CRYPTO_ARC4=y
# CONFIG_CRYPTO_KHAZAD is not set
# CONFIG_CRYPTO_ANUBIS is not set
# CONFIG_CRYPTO_DEFLATE is not set
CONFIG_CRYPTO_MICHAEL_MIC=y
CONFIG_CRYPTO_CRC32C=y
# CONFIG_CRYPTO_TEST is not set

#
# Hardware crypto devices
#
# CONFIG_CRYPTO_DEV_PADLOCK is not set




And compile It :

make && make modules_install

Copy the kernel image in /boot :

cp arch/i386/boot/bzImage /boot/kernel-2.6.17-gentoo-r8
cp arch/i386/boot/.config /boot/config-kernel-2.6.17-gentoo-r5
  • Set /etc/fstab :

You can download it here : :linux:fstab.

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't 
# needed; notail increases performance of ReiserFS (at the expense of storage 
# efficiency).  It's safe to drop the noatime options if you want and to 
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>			<mountpoint>	<type>		<opts>		<dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/hda1		/boot		ext2		defaults,noatime	1 2
/dev/hda3		/		reiserfs		noatime		0 1
/dev/hda2		none		swap		sw		0 0
/dev/cdrom      	/mnt/cdrom	iso9660		noauto,user	0 0
#/dev/cdroms/cdrom0	/mnt/cdrom	iso9660		noauto,user	0 0
/dev/sda1               /mnt/ipod       vfat            noauto,user     0 0
/dev/sda1               /mnt/cam        vfat            noauto,user     0 0
#/dev/fd0		/mnt/floppy	auto		noauto		0 0

# NOTE: The next line is critical for boot!
proc			/proc		proc		defaults	0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for 
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
shm			/dev/shm	tmpfs		nodev,nosuid,noexec	0 0

  • Set the hostname /etc/conf.d/hostname :
HOSTNAME="hermes"
* network informations :

/etc/hosts

# /etc/hosts:  This file describes a number of hostname-to-address
#              mappings for the TCP/IP subsystem.  It is mostly
#              used at boot time, when no name servers are running.
#              On small systems, this file can be used instead of a
#              "named" name server.  Just add the names, addresses
#              and any aliases to this file...
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/hosts,v 1.8 2003/08/04 20:12:25 azarah Exp $
#
127.0.0.1     hermes.homenetwork hermes localhost

  • Network at boot-time :

</code> rc-update add net.eth0 default </code>

  • System informations :

Set teh root password :

passwd

FIXME : /etc/rc.conf ; /etc/conf.d/keymaps (fr) ; /etc/conf.d/clock (local).

  • log manager :
emerge syslog-ng
rc-update add syslog-ng default
  • File tools :
emerge reiserfsprogs
  • DHCP client :
emerge dhcpcd
  • Uitilities :
emerge pciutils usbutils

The bootloader

Grub and /boot/grub/grub.conf :linux:grub.conf

emerge grub
default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=Gentoo-2.6.16-r10
root(hd0,0)
kernel /boot/kernel-2.6.16-gentoo-r10 root=/dev/hda3

title=Gentoo-2.6.16-r7
root(hd0,0)
kernel /boot/kernel-2.6.16-gentoo-r7 root=/dev/hda3

title=Gentoo-2.6.16-r7-acpi
root(hd0,0)
kernel /boot/kernel-2.6.16-gentoo-r7-acpi root=/dev/hda3
grep -v rootfs /proc/mounts > /etc/mtab
grub-install /dev/hda
  • add a user :
useradd -m -G users,wheel,audio,video,portage -s /bin/bash stan
passwd stan

X server

To install modular X :

emerge xorg-x11
emerge ati-drivers
eselect opengl set ati

Check your /etc/X11/xorg.conf :linux:xorg.conf :


Section "ServerLayout"

	Identifier     "Simple Layout"
	Screen         "Screen 1" 0 0
	InputDevice    "Mouse1" "CorePointer"
	InputDevice    "Keyboard1" "CoreKeyboard"


	Option  "BlankTime"  "2"  # Blank the screen after 5 minutes (Fake)
	Option  "StandbyTime"  "5"  # Turn off screen after 10 minutes (DPMS)
	Option  "SuspendTime"  "15"  # Full suspend after 20 minutes
	Option  "OffTime"  "30"  # Turn off after half an hour
	#Option  "AIGLX" "true"
EndSection

Section "Files"

	FontPath     "/usr/share/fonts/misc"
	FontPath     "/usr/share/fonts/75dpi"
	FontPath     "/usr/share/fonts/100dpi"
	FontPath     "/usr/share/fonts/Type1"
	FontPath     "/usr/share/fonts/terminus"
EndSection

Section "Module"

    Load       "glx"
    Load       "dri"
	Load  "dbe"  	# Double buffer extension
	SubSection "extmod"
		Option	    "omit xfree86-dga"   # don't initialise the DGA extension
	EndSubSection
	Load  "freetype"
EndSection

Section "InputDevice"

	Identifier  "Keyboard1"
	Driver      "kbd"
	Option	    "AutoRepeat" "500 30"
# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))
	Option	    "XkbRules" "xorg"
	Option	    "XkbModel" "pc105"
	Option	    "XkbLayout" "fr"
EndSection

Section "InputDevice"

	Identifier  "Mouse1"
	Driver      "mouse"
	Option	    "Protocol" "Auto"	# Auto detect
	Option	    "Device" "/dev/input/mice"
# When using XQUEUE, comment out the above two lines, and uncomment
	Option	    "ZAxisMapping" "4 5 6 7"
# Emulate3Buttons is an option for 2-button mice
EndSection

Section "Monitor"

	Identifier   "vaio"
	HorizSync    31.5 - 82.0
	VertRefresh  50.0 - 100.0
	Option  "DPMS"  "true"
EndSection

Section "Device"

	Identifier  "Standard VGA"
	Driver      "vga"
	VendorName  "Unknown"
	BoardName   "Unknown"
EndSection

Section "Device"

	Identifier  "9700"
	Driver      "fglrx"
	Option      "XAANoOffscreenPixmaps" "true"
	Option      "DRI" "true"
EndSection

Section "Screen"
	Identifier "Screen 1"
	Device     "9700"
	Monitor    "vaio"
	DefaultDepth     24
	SubSection "Display"
		Viewport   0 0
		Depth     8
		Modes    "1280x1024" "1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
		Modes    "1280x1024" "1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
		Modes    "1920x1200" "1024x768" "800x600" "640x480"
	EndSubSection
EndSection

Section "dri"
  Mode 0666
EndSection 

### comment out if you need compositing. Beware, It desactivate direct rendering with figlrx <= 8.28.8) ###
#Section "Extensions"
#	Option "Composite" "Enable"
#EndSection

If you want :

emerge --pretend --verbose -uD world

WifiX

Device Drivers --->
   Generic Driver Options --->
    [] ??
    [] ??
    <*> userspace firmware support

/bin/sh /usr/portage/net-wireless/ieee80211/files/remove-old /usr/src/linux
/bin/sh /usr/portage/net-wireless/ieee80211/files/remove-old /lib/modules/2.6.17-gentoo-r8/build

emerge wireless-tools wpa_supplicant ipw2200-firmware ipw2200

modprobe ipw2200
modprobe ieee80211_crypt_tkip
modprobe ieee80211_crypt_ccmp




/etc/module.autoload.d/kernel-2.6 :

fglrx
ipw2200
ieee80211_crypt_tkip
ieee80211_crypt_ccmp

~                                                                               
~                                          

/etc/wpa_supplicant/wpa_supplicant.conf :

      
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1

                                                                    
        network={
        key_mgmt=NONE
        priority=-9999999
}

network={
        ssid="StanWarehouse"
        psk="thisisapassphrase"
        priority=5
}

           

/etc/conf.d/net :

dhcpcd_eth0="-t 6"
modules=( "wpa_supplicant" )
wpa_supplicant_eth1="-Dwext -c /etc/wpa_supplicant/wpa_supplicant.conf"
wpa_timeout_ath0=10

Add a symlink to net.lo :

cd /etc/init.d
ln -s net.lo net.eth1

Check if it starts :

hermes init.d # /etc/init.d/net.eth1 start
 * Starting eth1
 *   Starting wpa_supplicant on eth1 ...                                  [ ok ]
 *   Starting wpa_cli on eth1 ...                                         [ ok ]
 *     Backgrounding ...
hermes init.d # 

cpufreq scaling

FIXME add the battery runlevel.

rc-update add acpid default
emerge cpufrequtils
emerge cpufreqd
/etc/init.d/cpufreqd start
rc-update add cpufreqd default 

/etc/cpufreqd.conf

General]
pidfile=/var/run/cpufreqd.pid
poll_interval=3
enable_plugins=acpi_ac, acpi_battery
enable_remote=1
remote_group=wheel
verbosity=5
[/General]

[Profile]
name=ondemand
minfreq=0%
maxfreq=100%
policy=ondemand
[/Profile]

[Profile]
name=conservative
minfreq=0%
maxfreq=100%
policy=conservative
[/Profile]

[Profile]
name=powersave
minfreq=0%
maxfreq=100%
policy=powersave
[/Profile]

[Profile]
name=performance
minfreq=0%
maxfreq=100%
policy=performance
[/Profile]

[Rule]
name=battery
ac=off
profile=conservative
[/Rule]

[Rule]
name=battery_low
ac=off
battery_interval=0-10
profile=powersave
[/Rule]

[Rule]
name=ac
ac=on
profile=ondemand
[/Rule]


Miscellanous power-safe tools

FIXME mobo-check apm Vs acpi (acpid atm).


emerge laptop-mode-tools

Now, configure /etc/laptop-mode/laptop-mode.conf as you wish and run it : FIXME use the battery run level.


/etc/init.d/laptop_mode start
rc-update add laptop_mode default

softkeys, LCD brightness, etc

We need sonypid to intercept softkeys and spicctrl to talk with the sonypi driver. (Do not forget to compile the kernel with sonypi driver).

emerge sonypid spicctrl

Add :this file (remove the .txt extension) in /etc/init.d/ and to start at default runlevel, edit /etc/conf.d/local.start :

# /etc/conf.d/local.start

# This is a good place to load any misc programs
# on startup ( use 1>&2 to hide output)
perl /etc/init.d/sonypidd

/etc/init.d/sonypidd :

#!/usr/bin/perl
###########
#
# Daemon to monitor sonypi events and do things, on machines that have
# the sony programmable I/O device. Requires the "sonypid" daemon as 
# input, and the "spicctrl" and "readeontool" programs for output.
#
# There is a table of actions to take for each sonypi function-key event.  
# Only a few of the events (notably eject, brightness, video out, and 
# suspend to disk) are used.
# 
# The path may need customization for your system; it works on my VGN-A197
# machine with Debian sarge and radeontool and sonypid installed in
# /usr/local/bin.
#
# Best of luck; questions, comments, or revisions may be directed to 
# "deforest@boulder.swri.edu".
#
# Copyright Craig DeForest, 2003
#
# Minor adjustments to fit into Debian's framework and support 
# Sony's VAIO A-Series by Denny Priebe, 2004
#
# You may distribute this under the terms of the GPL version 2; the 
# complete license is available at http://www.gnu.org/licenses/gpl.txt
#

$ENV{PATH}  = '/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV LD_LIBRARY_PATH)};

##########
# Some setup variables collected here for convenience

$bright_steps = 10;
$spicctrl = 'spicctrl';

# /dev/cdrom is usally a good idea. Change this if needed.
$cdrom = "/dev/cdrom";

# Change this to the command that usually suspends your machine.
# It differs between the existing implementations (pmdisk, swsusp, swsusp2)
$suspend_command = "true";

##########
# Some brightness settings
$minbs = 0;
$maxbs = 255;
$bs = ($maxbs-$minbs+1)/$bright_steps;

##########
# What to do when the raise brightness key is hit
$brighter = sub {
    $B =  int(`$spicctrl -B`) + int($bs);
    if ($B <= $maxbs) {
       `$spicctrl -b $B`;
    }
};

##########
# What to do when the lower brightness key is hit
$darker = sub {
    $B = int(`$spicctrl -B`) - int($bs);
    if ($B >= $minbs) {
       `$spicctrl -b $B`;
    }
};

##########
# What to do when the toggle video out key is hit
$toggle_vo = sub {
    $rv = `radeontool dac`;
    @words = split(m/\s+/,$rv);
    $status = $words[$#words];
    $ns = "off" if $status eq "on";
    $ns = "on" if $status eq "off";
    `radeontool dac $ns && logger -t sonypidd "Video out is $ns"`;
};

##########
# What to do when the suspend key is hit
$suspend = sub {
    `logger -t sonypidd "Suspending"`;
    `$suspend_command`;
};

##########
# Table of function-key actions.  List ref containing strings 
# executes strings as shell commands; code ref gets executed in situ.

%cmds = (
          "F5"  => $darker,                  # Fn-F5 - decrease brightness
          "F6"  => $brighter,                # Fn-F6 - increase brightness
          "F7"  => $toggle_vo,               # Fn-F7 - toggle video out
          "F12" => $suspend,                 # Fn-F12 - suspend to disk
          "E"   => ["eject $cdrom"],         # Eject button aka Fn-E
        );

#
# Daemon stuff -- check the lockfile (There Can Only Be One!) and 
# spawn twice to disassociate from the terminal.
# 
if(open FILE,"</var/run/sonypidd.pid" ) {
    chomp($otherpid = <FILE>);
    @lines = `ps -e`;
    @found = grep(/^\s*$otherpid\s/o && /sonypidd/,@lines);
    if(@found) {
	print STDERR "Sonypidd is already running (PID $otherpid)\n";
	exit(1);
    }
}

open FILE,">/var/run/sonypidd.pid" || die "Couldn't open lock file\n";
exit 0 if(fork);
exit 0 if(fork);
print FILE $$,"\n";
close FILE;


##########
# Open a sonypid process to read the sonypi device
pipe READ,WRITE;
$pid = fork();
$| = 1;
if(!$pid) {
    close READ;
    open STDERR,">&WRITE";
    open STDOUT,">&WRITE";
    exec('sonypid');
    die;
}
close WRITE;

##########
# Interrupt handling -- clean up the sonypid before dying...
$die = sub{ kill(9,$pid); unlink("/var/run/sonypidd.pid"); exit 1; };
$SIG{HUP} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = $die;


##########
# Event loop -- grab the function-key events, look 'em up, and do 'em.
# Go away as soon as the sonypid dies.

while(defined(  $_ = <READ> )){
  s/^Event:\s*//;
  @words = split(m/\s+/,$_);

  if($words[0] =~ m/^Fn-([0-9A-Za-z]+)$/) {
      my $f_no = $1;
      if(defined($cmds{$f_no})) {
	  if(ref $cmds{$f_no} eq 'CODE') {
	      &{$cmds{$f_no}};
	  } elsif(ref $cmds{$f_no} eq 'ARRAY') {
	      for(@{$cmds{$f_no}}) {
		  `$_`;
	      }
	  }
      }
  }
}

exit 0;



Window manager

emerge gnome sensors-applet

set your ~/.xinitrc :


Alsa sound

I assume you have compiled the driver in the kernel, etc.

emerge alsa-utils
rc-update add alsasound boot
/etc/init.d alsasound start

Use *alsamixer* to control the sound, don’t forget to unmute master and pcm.

Portage configuration

Portage is the core of your Gentoo system. FIXME a portage introduction.

Finalizing the installation

A good reflex is to keep your system up-to-date, and a fresh install does not mean up-to-date install !!

try this (as root) :

emerge --pretend --verbose -uD world
Note

To reach the BIOS configuration, press F2 at startup.
To reach the hardware’s boot options, press F1 at startup.

Personal

  • subversion
  • rxvt
  • vim, supertab
  • terminus-font
  • ~/.Xdefaults
# Xcursor.theme: gentoo-silver
Xcursor.theme: Jimmac
Xcursor.size: 24


rxvt.font: -xos4-terminus-medium-r-normal--14-140-72-72-c-80-*
rxvt.boldFont: -xos4-terminus-bold-r-normal--14-140-72-72-c-80-*
rxvt.realBold: True
#rxvt.inheritPixmap: True
#rxvt.background: #000000
rxvt.background: #ffffff
#rxvt.foreground: #ffffff
rxvt.foreground: #000000
rxvt.scrollBar: False
rxvt.visualBell:False
rxvt.internalBorder: 3
rxvt.externalBorder: 0
rxvt.tintColor: #663333
rxvt.saveLines: 10000
rxvt.jumpScroll: true
rxvt.multiScroll: true

In xorg.conf, add this :

 FontPath   "/usr/share/fonts/terminus"
  • .vimrc :
scriptencoding utf-8

"-----------------------------------------------------------------------
" Vim settings file for Ciaran McCreesh
"
" I finally added some comments, so you can have some vague idea of
" what all this does.
"
" Most recent update: mar 05 sep 2006 12:03:19 CEST
"
" Don't just blindly copy this vimrc. There's some rather idiosyncratic
" stuff in here...
"
"-----------------------------------------------------------------------

"-----------------------------------------------------------------------
" terminal setup
"-----------------------------------------------------------------------

" Extra terminal things
set termencoding=iso8859-15
if (&term == "rxvt-unicode") && (&termencoding == "")
    "set termencoding=utf-8
    set termencoding=iso8859-15
endif

if &term =~ "xterm" || &term == "rxvt-unicode"
    if exists('&t_SI')
        let &t_SI = "\<Esc>]10;lightgoldenrod\x7"
        let &t_EI = "\<Esc>]10;grey80\x7"
    endif
endif

"-----------------------------------------------------------------------
" settings
"-----------------------------------------------------------------------

" Don't be compatible with vi
set nocompatible

" Enable a nice big viminfo file
set viminfo='1000,f1,:1000,/1000
set history=500

" Make backspace delete lots of things
set backspace=indent,eol,start

" Create backups
set backup

" Show us the command we're typing
set showcmd

" Highlight matching parens
let loaded_matchparen = 1
set showmatch
"set matchpairs=

" Search options: incremental search, do clever case things, highlight
" search
set incsearch
set ignorecase
set infercase
set hlsearch

" Show full tags when doing search completion
set showfulltag

" Speed up macros
set lazyredraw

" No annoying error noises
set noerrorbells
set visualbell t_vb=
if has("autocmd")
    autocmd GUIEnter * set visualbell t_vb=
endif

" Try to show at least three lines and two columns of context when
" scrolling
set scrolloff=3
set sidescrolloff=2

" Wrap on these
set whichwrap+=<,>,[,]

" Use the cool tab complete menu
set wildmenu
set wildignore=*.o,*~

" Allow edit buffers to be hidden
set hidden

" 1 height windows
set winminheight=1

" Enable syntax highlighting
if has("syntax")
    syntax on
endif

" Set our fonts
if has("gui_kde")
    "set guifont=Terminus/12/-1/5/50/0/0/0/0/0
    set guifont=-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso8859-15
elseif has("gui_gtk")
    "set guifont=Terminus\ 12
    set guifont=-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso8859-15
elseif has("gui_running")
    "set guifont=-xos4-terminus-medium-r-normal--12-140-72-72-c-80-iso8859-1
    set guifont=-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso8859-15
endif

" Try to load a nice colourscheme
if has("eval")
    fun! LoadColourScheme(schemes)
        let l:schemes = a:schemes . ":"
        while l:schemes != ""
            let l:scheme = strpart(l:schemes, 0, stridx(l:schemes, ":"))
            let l:schemes = strpart(l:schemes, stridx(l:schemes, ":") + 1)
            try
                exec "colorscheme" l:scheme
                break
            catch
            endtry
        endwhile
    endfun

    if has('gui')
        call LoadColourScheme("inkpot:night:rainbow_night:darkblue:elflord")
    else
        if &t_Co == 88 || &t_Co == 256
            call LoadColourScheme("inkpot:darkblue:elflord")
        else
            call LoadColourScheme("darkblue:elflord")
        endif
    endif
endif

" No icky toolbar, menu or scrollbars in the GUI
if has('gui')
    set guioptions-=m
    set guioptions-=T
    set guioptions-=l
    set guioptions-=L
    set guioptions-=r
    set guioptions-=R
end

" By default, go for an indent of 2
set shiftwidth=2

" Do clever indent things. Don't make a # force column zero.
set autoindent
set smartindent
inoremap # X<BS>#

" Enable folds
if has("folding")
    set foldenable
    set foldmethod=indent
endif

" Syntax when printing
set popt+=syntax:y

" Enable filetype settings
if has("eval")
    filetype on
    filetype plugin on
    filetype indent on
endif

" Enable modelines only on secure vim versions
if (v:version == 603 && has("patch045")) || (v:version > 603)
    set modeline
else
    set nomodeline
endif

" Nice statusbar
set laststatus=2
set statusline=
set statusline+=%-3.3n\                      " buffer number
set statusline+=%f\                          " file name
set statusline+=%h%m%r%w                     " flags
set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding},                " encoding
set statusline+=%{&fileformat}]              " file format
if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
    set statusline+=\ %{VimBuddy()}          " vim buddy
endif
set statusline+=%=                           " right align
set statusline+=0x%-8B\                      " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P        " offset

" If possible, try to use a narrow number column.
if v:version >= 700
    try
        setlocal numberwidth=3
    catch
    endtry
endif

" Include $HOME in cdpath
if has("file_in_path")
    let &cdpath=','.expand("$HOME").','.expand("$HOME").'/work'
endif

" Better include path
set path+=src/
set path+=/usr/lib/gcc-lib/**/include/g++-v3/**

" Show tabs and trailing whitespace visually
if (&termencoding == "utf-8") || has("gui_running")
    if v:version >= 700
        set list listchars=tab:����,trail:��,extends:���,nbsp:���
    else
        set list listchars=tab:����,trail:��,extends:���
    endif
else
    if v:version >= 700
        set list listchars=tab:>-,trail:.,extends:>,nbsp:_
    else
        set list listchars=tab:>-,trail:.,extends:>
    endif
endif

set fillchars=fold:-

"-----------------------------------------------------------------------
" completion
"-----------------------------------------------------------------------
set dictionary=/usr/share/dict/words

"-----------------------------------------------------------------------
" autocmds
"-----------------------------------------------------------------------

if has("eval")

    " If we're in a wide window, enable line numbers.
    fun! <SID>WindowWidth()
        if winwidth(0) > 1000
            setlocal foldcolumn=0
            setlocal number
        else
            setlocal nonumber
            setlocal foldcolumn=0
        endif
    endfun

    " Force active window to the top of the screen without losing its
    " size.
    fun! <SID>WindowToTop()
        let l:h=winheight(0)
        wincmd K
        execute "resize" l:h
    endfun

    " Force active window to the bottom of the screen without losing its
    " size.
    fun! <SID>WindowToBottom()
        let l:h=winheight(0)
        wincmd J
        execute "resize" l:h
    endfun

    " Update .*rc header
    fun! <SID>UpdateRcHeader()
        let l:c=col(".")
        let l:l=line(".")
        1,10s-\(Most recent update:\).*-\="Most recent update: ".strftime("%c")-
e
        call cursor(l:l, l:c)
    endfun
endif

" Bon la on degage tout !!!!!!
" autocmds
if has("autocmd") && has("eval")
    augroup ciaranm
        autocmd!

        " Automagic line numbers
        autocmd BufEnter * :call <SID>WindowWidth()

        " Update header in .vimrc and .bashrc before saving
        autocmd BufWritePre *vimrc  :call <SID>UpdateRcHeader()
        autocmd BufWritePre *bashrc :call <SID>UpdateRcHeader()

        " Always do a full syntax refresh
        autocmd BufEnter * syntax sync fromstart

        " For help files, move them to the top window and make <Return>
        " behave like <C-]> (jump to tag)
        autocmd FileType help :call <SID>WindowToTop()
        autocmd FileType help nmap <buffer> <Return> <C-]>

        " For the quickfix window, move it to the bottom
        autocmd FileType qf :3 wincmd _ | :call <SID>WindowToBottom()

        " For svn-commit, don't create backups
        "autocmd BufRead svn-commit.tmp :setlocal nobackup

        " Detect procmailrc
        "autocmd BufRead procmailrc :setfiletype procmail

        " bash-completion ftdetects
        autocmd BufNewFile,BufRead /*/*bash*completion*/*
                    \ if expand("<amatch>") !~# "ChangeLog" |
                    \     let b:is_bash = 1 | set filetype=sh |
                    \ endif

        try
            " if we have a vim which supports QuickFixCmdPost (patch by
            " ciaranm, marked for inclusion in vim7), give us an error
            " window after running make, grep etc, but only if results are
            " available.
            autocmd QuickFixCmdPost * :cwindow 5

            " Similarly, try to automatically run ./configure and / or
            " autogen if necessary.
            autocmd QuickFixCmdPre make
                        \ if ! filereadable('Makefile') |
                        \     if ! filereadable("configure") |
                        \         exec "! ./autogen.bash" |
                        \     endif |
                        \     if filereadable("configure") |
                        \         exec "! ./configure --disable-doxygen" |
                        \     endif |
                        \ endif
        catch
        endtry

        try
            autocmd Syntax *
                        \ syn match VimModelineLine /^.\{-1,}vim:[^:]\{-1,}:.*/
contains=VimModeline |
                        \ syn match VimModeline contained /vim:[^:]\{-1,}:/
            hi def link VimModelineLine comment
            hi def link VimModeline     special
        catch
        endtry
    augroup END
endif

" content creation
if has("autocmd")
    augroup content
        autocmd BufNewFile *.rb 0put ='# vim: set sw=4 sts=4 et tw=80 :' |
                    \ 0put ='#!/usr/bin/ruby' | set sw=4 sts=4 et tw=80 |
                    \ norm G

        autocmd BufNewFile *.hh 0put ='/* vim: set sw=4 sts=4 et foldmethod=synt
ax : */' |
                    \ 1put ='' | call MakeIncludeGuards() |
                    \ 5put ='#include \"config.h\"' |
                    \ set sw=4 sts=4 et tw=80 | norm G

        autocmd BufNewFile *.cc 0put ='/* vim: set sw=4 sts=4 et foldmethod=synt
ax : */' |
                    \ 1put ='' | 2put ='' | call setline(3, '#include "' .
                    \ substitute(expand("%:t"), ".cc$", ".hh", "") . '"') |
                    \ set sw=4 sts=4 et tw=80 | norm G

        autocmd BufNewFile configure.ac
                    \ 0put ='dnl vim: set sw=8 sts=8 noet :' |
                    \ $put ='' |
                    \ call setline(line('$'), 'AC_INIT([' . substitute(expand('%
:p:h'),
                    \     '^.\{-}/\([^/]\+\)\(/trunk\)\?$', '\1', '') . '], [0.0
])') |
                    \ $put ='AC_PREREQ(2.5)' |
                    \ $put ='AC_CONFIG_SRCDIR([])' |
                    \ $put ='AC_CONFIG_AUX_DIR(config)' |
                    \ $put ='AM_INIT_AUTOMAKE(1.9)' |
                    \ $put ='' |
                    \ $put ='dnl check for required programs' |
                    \ $put ='AC_PROG_CXX' |
                    \ $put ='AC_PROG_INSTALL' |
                    \ $put ='AC_PROG_LN_S' |
                    \ $put ='AC_PROG_RANLIB' |
                    \ $put ='AC_PROG_MAKE_SET' |
                    \ $put ='' |
                    \ $put ='dnl output' |
                    \ $put ='AM_CONFIG_HEADER(config.h)' |
                    \ $put ='AC_OUTPUT(' |
                    \ $put ='   Makefile' |
                    \ $put ='   src/Makefile' |
                    \ $put ='   )' |
                    \ set sw=8 sts=8 noet |
                    \ norm ggjjjjf]

        autocmd BufNewFile autogen.bash
                    \ 0put ='#!/usr/bin/env bash' |
                    \ 1put ='# vim: set sw=4 sts=4 et tw=80 :' |
                    \ $put ='run() {' |
                    \ $put ='echo \">>> $@\"' |
                    \ $put ='    if ! $@ ; then' |
                    \ $put ='        echo \"oops!\" 1>&2' |
                    \ $put ='        exit 127' |
                    \ $put ='    fi' |
                    \ $put ='}' |
                    \ $put ='' |
                    \ $put ='get() {' |
                    \ $put ='    type ${1}-${2}    &>/dev/null && echo ${1}-${2}
    && return' |
                    \ $put ='    type ${1}${2//.}  &>/dev/null && echo ${1}${2//
.}  && return' |
                    \ $put ='    type ${1}         &>/dev/null && echo ${1}
    && return' |
                    \ $put ='    echo \"Could not find ${1} ${2}\" 1>&2' |
                    \ $put ='    exit 127' |
                    \ $put ='}' |
                    \ $put ='' |
                    \ $put ='run mkdir -p config' |
                    \ $put ='run $(get libtoolize 1.5 ) --copy --force --automak
e' |
                    \ $put ='rm -f config.cache' |
                    \ $put ='run $(get aclocal 1.9 )' |
                    \ $put ='run $(get autoheader 2.59 )' |
                    \ $put ='run $(get autoconf 2.59 )' |
                    \ $put ='run $(get automake 1.9 ) -a --copy' |
                    \ set sw=4 sts=4 et tw=80 |
                    \ norm gg=Ggg

        autocmd BufNewFile Makefile.am
                    \ 0put ='CLEANFILES = *~' |
                    \ if (! filereadable(expand("%:p:h:h") . '/Makefile.am')) |
                    \     $put ='MAINTAINERCLEANFILES = Makefile.in configure co
nfig/* aclocal.m4 \' |
                    \     $put ='' |
                    \     call setline(line('$'), "\t\t\tconfig.h config.h.in")
|
                    \     $put ='AUTOMAKE_OPTIONS = foreign dist-bzip2' |
                    \     $put ='EXTRA_DIST = autogen.bash' |
                    \ else |
                    \     $put ='MAINTAINERCLEANFILES = Makefile.in' |
                    \ endif

    augroup END
endif

"-----------------------------------------------------------------------
" mappings
"-----------------------------------------------------------------------

nmap   <silent> <S-Right>  :bnext<CR>

" Delete a buffer but keep layout
if has("eval")
    command! Kwbd enew|bw #
    nmap     <C-w>!   :Kwbd<CR>
endif

" Annoying default mappings
inoremap <S-Up>   <C-o>gk
inoremap <S-Down> <C-o>gj
noremap  <S-Up>   gk
noremap  <S-Down> gj

" Make <space> in normal mode go down a page rather than left a
" character
"noremap <space> <C-f>

" Useful things from inside imode
inoremap <C-z>w <C-o>:w<CR>
inoremap <C-z>q <C-o>gq}<C-o>k<C-o>$

" Commonly used commands
nmap <silent> <F3> :silent nohlsearch<CR>
imap <silent> <F3> <C-o>:silent nohlsearch<CR>
nmap <F5> <C-w>c
nmap <F4> :Kwbd<CR>
nmap <F6> :compiler tex<CR>
nmap <F4> :Kwbd<CR>
nmap <F8> :make<CR>
nmap <F7> :make check<CR>
nmap <F12> :pop<CR>

" Insert a single char
noremap <Leader>i i<Space><Esc>r

" Split the line
nmap <Leader>n \i<CR>

" Pull the following line to the cursor position
noremap <Leader>J :s/\%#\(.*\)\n\(.*\)/\2\1<CR>

" In normal mode, jj escapes
inoremap jj <Esc>

" Kill line
noremap <C-k> "_dd

" Select everything
noremap <Leader>gg ggVG

" Reformat everything
noremap <Leader>gq gggqG

" Reformat paragraph
noremap <Leader>gp gqap

" Clear lines
noremap <Leader>clr :s/^.*$//<CR>:nohls<CR>

" Delete blank lines
noremap <Leader>dbl :g/^$/d<CR>:nohls<CR>

" Enclose each selected line with markers
noremap <Leader>enc :<C-w>execute
            \ substitute(":'<,'>s/^.*/#&#/ \| :nohls", "#", input(">"), "g")<CR>

" Enable fancy % matching
if has("eval")
    runtime! macros/matchit.vim
endif

" q: sucks
nmap q: :q

" set up some more useful digraphs
if has("digraphs")
    digraph ., 8230    " ellipsis (���)
endif

if has("eval")
    " GNU format changelog entry
    fun! MakeChangeLogEntry()
        norm gg
        /^\d
        norm 2O
        norm k
        call setline(line("."), strftime("%Y-%m-%d") .
                    \ " Ciaran McCreesh")
        norm 2o
        call setline(line("."), "\t* ")
        norm $
    endfun
    noremap ,cl :call MakeChangeLogEntry()<CR>

    " Work out include guard text
    fun! IncludeGuardText()
        let l:t = substitute(expand("%:p"), '^.\{-}/\([^/]\+\)/\(trunk/\)\?src/.
*',
                    \ '\1', '')
        let l:t = l:t . "_" . substitute(expand("%:p"), '^.\{-}/\(trunk/\)\?src/
', "", "")
        let l:t = substitute(l:t, "/", "_", "g")
        let l:t = substitute(l:t, "\.hh$", "", "")
        if l:t =~ /^HOME/
            let l:t = expand("%:p:t")
        endif
        let l:t = "HAVE_" . toupper(l:t) . "_HH"
        return l:t
    endfun

    " Make include guards
    fun! MakeIncludeGuards()
        norm gg
        /^$/
        norm 2O
        call setline(line("."), "#ifndef " . IncludeGuardText())
        norm o
        call setline(line("."), "#define " . IncludeGuardText() . " 1")
        norm G
        norm o
        call setline(line("."), "#endif")
    endfun
    noremap ,ig :call MakeIncludeGuards()<CR>

    " command aliases, can't call these until after cmdalias.vim is loaded
    au VimEnter * if exists("loaded_cmdalias") |
                \       call CmdAlias("mkdir",   "!mkdir") |
                \       call CmdAlias("cvs",     "!cvs") |
                \       call CmdAlias("svn",     "!svn") |
                \       call CmdAlias("commit",  "!svn commit -m \"") |
                \       call CmdAlias("upload",  "make upload") |
                \ endif
endif

" fast buffer switching
if v:version >= 700 && has("eval")
    let g:switch_header_map = {
                \ 'cc':    'hh',
                \ 'hh':    'cc',
                \ 'c':     'h',
                \ 'h':     'c',
                \ 'cpp':   'hpp',
                \ 'hpp':   'cpp' }

    fun! SwitchTo(f, split) abort
        if ! filereadable(a:f)
            echoerr "File '" . a:f . "' does not exist"
        else
            if a:split
                new
            endif
            if 0 != bufexists(a:f)
                exec ':buffer ' . bufnr(a:f)
            else
                exec ':edit ' . a:f
            endif
        endif
    endfun

    fun! SwitchHeader(split) abort
        let filename = expand("%:p:r")
        let suffix = expand("%:p:e")
        if suffix == ''
            echoerr "Cannot determine header file (no suffix)"
            return
        endif

        let new_suffix = g:switch_header_map[suffix]
        if new_suffix == ''
            echoerr "Don't know how to find the header (suffix is " . suffix . "
)"
            return
        end

        call SwitchTo(filename . '.' . new_suffix, a:split)
    endfun

    fun! SwitchTest(split) abort
        let filename = expand("%:p:r")
        let suffix = expand("%:p:e")
        if -1 != match(filename, '_TEST$')
            let new_filename = substitute(filename, '_TEST$', '.' . suffix, '')
        else
            let new_filename = filename . '_TEST.' . suffix
        end
        call SwitchTo(new_filename, a:split)
    endfun

    noremap <Leader>sh :call SwitchHeader(0)<CR>
    noremap <Leader>st :call SwitchTest(0)<CR>
    noremap <Leader>ssh :call SwitchHeader(1)<CR>
    noremap <Leader>sst :call SwitchTest(1)<CR>
endif

" super i_c-y / i_c-e
if v:version >= 700 && has("eval")
    fun! SuperYank(offset)
        let l:cursor_pos = col(".")
        let l:this_line = line(".")
        let l:source_line = l:this_line + a:offset
        let l:this_line_text = getline(l:this_line)
        let l:source_line_text = getline(l:source_line)
        let l:add_text = ""

        let l:motion = "" . nr2char(getchar())
        if -1 != match(l:motion, '\d')
            let l:count = 0
            while -1 != match(l:motion, '\d')
                let l:count = l:count * 10 + l:motion
                let l:motion = "" . nr2char(getchar())
            endwhile
        else
            let l:count = 1
        endif

        if l:motion == "$"
            let l:add_text = strpart(l:source_line_text, l:cursor_pos - 1)
        elseif l:motion == "w"
            let l:add_text = strpart(l:source_line_text, l:cursor_pos - 1)
            let l:add_text = substitute(l:add_text,
                        \ '^\(\s*\%(\S\+\s*\)\{,' . l:count . '}\)\?.*', '\1', '
')
        elseif l:motion == "f" || l:motion == "t"
            let l:add_text = strpart(l:source_line_text, l:cursor_pos - 1)
            let l:char = nr2char(getchar())
            let l:pos = matchend(l:add_text,
                        \ '^\%([^' . l:char . ']\{-}' . l:char . '\)\{' . l:coun
t . '}')
            if -1 != l:pos
                let l:add_text = strpart(l:add_text, 0, l:motion == "f" ? l:pos
: l:pos - 1)
            else
                let l:add_text = ''
            endif
        else
            echo "Unknown motion: " . l:motion
        endif

        if l:add_text != ""
            let l:new_text = strpart(l:this_line_text, 0, l:cursor_pos - 1) .
                        \ l:add_text . strpart(l:this_line_text, l:cursor_pos -
1)
            call setline(l:this_line, l:new_text)
            call cursor(l:this_line, l:cursor_pos + strlen(l:add_text))
        endif
    endfun

    inoremap <C-g>y <C-\><C-o>:call SuperYank(-1)<CR>
    inoremap <C-g>e <C-\><C-o>:call SuperYank(1)<CR>
endif

"-----------------------------------------------------------------------
" abbreviations
"-----------------------------------------------------------------------

if has("autocmd")
    autocmd filetype cpp iabbrev <buffer> raise throw
    autocmd filetype cpp iabbrev <buffer> jns namespace
    autocmd filetype cpp iabbrev <buffer> jun using namespace
    autocmd filetype cpp iabbrev <buffer> jcl class
    autocmd filetype cpp iabbrev <buffer> jss std::string
    autocmd filetype cpp iabbrev <buffer> jsv std::vector
    autocmd filetype cpp iabbrev <buffer> jsl std::list
    autocmd filetype cpp iabbrev <buffer> jsm std::map
    autocmd filetype cpp iabbrev <buffer> jco const
    autocmd filetype cpp iabbrev <buffer> jvi virtual
    autocmd filetype cpp iabbrev <buffer> jpu public
    autocmd filetype cpp iabbrev <buffer> jpr protected
    autocmd filetype cpp iabbrev <buffer> jpv private
    autocmd filetype cpp iabbrev <buffer> jty typedef
    autocmd filetype cpp iabbrev <buffer> jcu CPPUNIT_ASSERT
    autocmd filetype cpp iabbrev <buffer> jce CPPUNIT_ASSERT_EQUAL
    autocmd filetype cpp iabbrev <buffer> jct CPPUNIT_ASSERT_THROW
endif

"-----------------------------------------------------------------------
" special less.sh and man modes
"-----------------------------------------------------------------------

if has("eval")
    fun! <SID>is_pager_mode()
        let l:ppidc = ""
        try
            if filereadable("/lib/libc.so.6")
                let l:ppid = libcallnr("/lib/libc.so.6", "getppid", "")
            elseif filereadable("/lib/libc.so.0")
                let l:ppid = libcallnr("/lib/libc.so.0", "getppid", "")
            else
                let l:ppid = ""
            endif
            let l:ppidc = system("ps -p " . l:ppid . " -o comm=")
            let l:ppidc = substitute(l:ppidc, "\\n", "", "g")
        catch
        endtry
        return l:ppidc ==# "less.sh" ||
                    \ l:ppidc ==# "vimpager" ||
                    \ l:ppidc ==# "manpager.sh" ||
                    \ l:ppidc ==# "vimmanpager"
    endfun

    if <SID>is_pager_mode()
        " we're in vimpager / less.sh / man mode
        set laststatus=0
        set ruler
        set foldmethod=manual
        set foldlevel=99
        set nolist
    endif
endif

"-----------------------------------------------------------------------
" plugin / script / app settings
"-----------------------------------------------------------------------

if has("eval")
    " Perl specific options
    let perl_include_pod=1
    let perl_fold=1
    let perl_fold_blocks=1

    " Vim specific options
    let g:vimsyntax_noerror=1

    " c specific options
    let g:c_gnu=1

    " eruby options
    au Syntax * hi link erubyRubyDelim Directory

    " Settings for taglist.vim
    let Tlist_Use_Right_Window=1
    let Tlist_Auto_Open=0
    let Tlist_Enable_Fold_Column=0
    let Tlist_Compact_Format=1
    let Tlist_WinWidth=28
    let Tlist_Exit_OnlyWindow=1
    let Tlist_File_Fold_Auto_Close = 1
    nnoremap <silent> <F9> :Tlist<CR>

    " Settings minibufexpl.vim
    let g:miniBufExplModSelTarget = 1
    let g:miniBufExplWinFixHeight = 1
    let g:miniBufExplWinMaxSize = 1
    " let g:miniBufExplForceSyntaxEnable = 1

    " Settings for showmarks.vim
    if has("gui_running")
        let g:showmarks_enable=1
    else
        let g:showmarks_enable=0
        let loaded_showmarks=1
    endif

    if has("autocmd")
        fun! <SID>FixShowmarksColours()
            if has('gui')
                hi ShowMarksHLl gui=bold guifg=#a0a0e0 guibg=#2e2e2e
                hi ShowMarksHLu gui=none guifg=#a0a0e0 guibg=#2e2e2e
                hi ShowMarksHLo gui=none guifg=#a0a0e0 guibg=#2e2e2e
                hi ShowMarksHLm gui=none guifg=#a0a0e0 guibg=#2e2e2e
                hi SignColumn   gui=none guifg=#f0f0f8 guibg=#2e2e2e
            endif
        endfun
        if v:version >= 700
            autocmd VimEnter,Syntax,ColorScheme * call <SID>FixShowmarksColours(
)
        else
            autocmd VimEnter,Syntax * call <SID>FixShowmarksColours()
        endif
    endif

    " Settings for explorer.vim
    let g:explHideFiles='^\.'

    " Settings for netrw
    let g:netrw_list_hide='^\.,\~$'

    " Settings for :TOhtml
    let html_number_lines=1
    let html_use_css=1
    let use_xhtml=1

    " cscope settings
    if has('cscope') && filereadable("/usr/bin/cscope")
        set csto=0
        set cscopetag
        set nocsverb
        if filereadable("cscope.out")
            cs add cscope.out
        endif
        set csverb

        let x = "sgctefd"
        while x != ""
            let y = strpart(x, 0, 1) | let x = strpart(x, 1)
            exec "nmap <C-j>" . y . " :cscope find " . y .
                        \ " <C-R>=expand(\"\<cword\>\")<CR><CR>"
            exec "nmap <C-j><C-j>" . y . " :scscope find " . y .
                        \ " <C-R>=expand(\"\<cword\>\")<CR><CR>"
        endwhile
        nmap <C-j>i      :cscope find i ^<C-R>=expand("<cword>")<CR><CR>
        nmap <C-j><C-j>i :scscope find i ^<C-R>=expand("<cword>")<CR><CR>
    endif
endif

"-----------------------------------------------------------------------
" final commands
"-----------------------------------------------------------------------

" turn off any existing search
if has("autocmd")
    au VimEnter * nohls
endif

"-----------------------------------------------------------------------
" vim: set shiftwidth=2 softtabstop=2 expandtab tw=72                  :
stan@hermes ~ $


  • .bashrc :

export PATH=$HOME/bin/:$PATH


source $HOME/Bommings/setenv.sh
source $HOME/Bommings/bommings-base/setenv.sh

export PYTHONPATH=$HOME/Bommings/bommings_dev/ThkSE/branches:$PYTHONPATH

export TERM="rxvt"
cd $HOME/Bommings/bommings-dev/

####AIDDIAG####
alias clear_aiddiag='rm -f var/aiddiag/shm/*; clear_sema; clear_shm'
alias clear_sema='for i in `ipcs -s |grep \`whoami\` |grep "0x" | cut -c12-20`; do ipcrm -s $i; done'
alias clear_shm='for i in `ipcs -m |grep \`whoami\` |grep -v "^0x00000000" | cut -c12-20`; do ipcrm -m $i; done'

export LANG="fr_FR.ISO-8859-1"
export LC_ALL="fr_FR.ISO-8859-1"
#-----------------------------------
# Source global definitions (if any)
#-----------------------------------

if [ -f /etc/bashrc ]; then
        . /etc/bashrc   # --> Read /etc/bashrc, if present.
fi

#-------------------------------------------------------------
# Automatic setting of $DISPLAY (if not set already)
# This works for linux - your mileage may vary....
# The problem is that different types of terminals give
# different answers to 'who am i'......
# I have not found a 'universal' method yet
#-------------------------------------------------------------

#---------------
# Some settings
#---------------

ulimit -S -c 0          # Don't want any coredumps
set -o notify
set -o noclobber
set -o ignoreeof
set -o nounset
#set -o xtrace          # useful for debuging

# Enable options:
shopt -s cdspell
shopt -s cdable_vars
shopt -s checkhash
shopt -s checkwinsize
shopt -s mailwarn
shopt -s sourcepath
shopt -s no_empty_cmd_completion  # bash>=2.04 only
shopt -s cmdhist
shopt -s histappend histreedit histverify
shopt -s extglob        # necessary for programmable completion

# Disable options:
shopt -u mailwarn


#-----------------------
# Greeting, motd etc...
#-----------------------

# Define some colors first:
red='\e[0;31m'
RED='\e[1;31m'
blue='\e[0;34m'
BLUE='\e[1;34m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m'              # No Color
# --> Nice. Has the same effect as using "ansi.sys" in DOS.

# Looks best on a black background.....
date


#---------------
# Shell Prompt
#---------------
#===============================================================
#
# ALIASES AND FUNCTIONS
#
# Arguably, some functions defined here are quite big
# (ie 'lowercase') but my workstation has 512Meg of RAM, so .....
# If you want to make this file smaller, these functions can
# be converted into scripts.
#
# Many functions were taken (almost) straight from the bash-2.04
# examples.
#
#===============================================================

#-------------------
# Personnal Aliases
#-------------------

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# -> Prevents accidentally clobbering files.
alias mkdir='mkdir -p'

alias h='history'
alias j='jobs -l'
alias r='rlogin'
alias which='type -all'
alias ..='cd ..'
alias path='echo -e ${PATH//:/\\n}'
alias print='/usr/bin/lp -o nobanner -d $LPDEST'   # Assumes LPDEST is defined
alias pjet='enscript -h -G -fCourier9 -d $LPDEST'  # Pretty-print using enscript
alias background='xv -root -quit -max -rmode 5'    # Put a picture in the background
alias du='du -kh'
alias df='df -kTh'

# The 'ls' family (this assumes you use the GNU ls)
alias la='ls -Al'               # show hidden files
alias ls='ls -hF --color'       # add colors for filetype recognition
alias lx='ls -lXB'              # sort by extension
alias lk='ls -lSr'              # sort by size
alias lc='ls -lcr'              # sort by change time
alias lu='ls -lur'              # sort by access time
alias lr='ls -lR'               # recursive ls
alias lt='ls -ltr'              # sort by date
alias lm='ls -al |more'         # pipe through 'more'
alias tree='tree -Csu'          # nice alternative to 'ls'

# tailoring 'less'
alias more='less'
export PAGER=less
export LESSCHARSET='latin1'
export LESSOPEN='|/usr/bin/lesspipe.sh %s 2>&-' # Use this if lesspipe.sh exists
export LESS='-i -N -w  -z-4 -g -e -M -X -F -R -P%t?f%f \
:stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...'

# spelling typos - highly personnal :-)
alias xs='cd'
alias vf='cd'
alias moer='more'
alias moew='more'
alias kk='ll'

#----------------
# a few fun ones
#----------------
# aliases...
alias top='xtitle Processes on $HOST && top'
alias make='xtitle Making $(basename $PWD) ; make'
alias ncftp="xtitle ncFTP ; ncftp"


function ll(){ ls -l "$@"| egrep "^d" ; ls -lXB "$@" 2>&-| egrep -v "^d|total "; }
function te()  # wrapper around xemacs/gnuserv
{
    if [ "$(gnuclient -batch -eval t 2>&-)" == "t" ]; then
        gnuclient -q "$@";
    else
        ( xemacs "$@" &);
    fi
}


Ressources

 
linux/gentoo_install_sony.txt · Dernière modification: 2007/03/01 14:37
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki