Difference between pages "Package:Emacs" and "Lenovo Thinkpad T420"

(Difference between pages)
(.emacs)
 
(Installing Grub onto the Drive(Everyone))
 
Line 1: Line 1:
[[File:emacs-logo.png]]
+
 +
== Introduction ==
 +
Throughout, this article will assume the following:
 +
* You have installed Gentoo or Funtoo in the past.
 +
** If you haven't, this article will still serve you well, but please have either the official funtoo, or gentoo install guides open. We move through non-machine-specific bits with little elaboration.
 +
* Have a T420 or similar machine.
  
Emacs is a famous text editor, famous by its flexibility and extensibility. One manual describes it as "the extensible, customizable, self-documenting, real-time display editor".
+
Even if you do not have a T420, you may find this guide useful for:
 +
* Nvidia Optimus Cards.
 +
* Power management.
 +
* General setup.
  
This page is designed to give users a good place to share their config and settings for a nice emacs setup.
+
This installation assumes (For now) that the install is starting from an MS-Windows installation. If you are not on Windows, please add your favourite choice of steps, keep the emphasis on ease of understanding.
  
== Installing emacs ==
+
== Getting Started ==
To install {{Package|app-editors/emacs}}, run the following command:
+
You'll want to get yourself running off a LiveCD or LiveUSB to start. This guide will assume liveUSB, since some users find them more difficult to prepare, this is usually due to boot flag issues.
<console>
+
(Note: ''Live USB restore drives are nice to have in general! The author keeps one in his college binder.'')
###i## emerge -av emacs
+
</console>
+
for the standard gnu emacs {{Package|app-editors/xemacs}} and
+
<console>
+
###i## emerge -av xemacs
+
</console>
+
  
for the 1980 created fork of emacs, both should handle the same, while emacs on its own stands here for both. If you install additional extensions for both you might need to add <tt>app-emacs</tt> or <tt>app-xemacs</tt> to the package as there are two different versions for both.
+
==== Windows ====
 +
We can use LiLi for this, it provides a nice, simple interface and is fairly reliable: [http://www.linuxliveusb.com/en/download LiLi Download]
  
== What emacs is and what it is not ==
+
=== SysrescueCD ===
 +
Grab the version that Suites your needs here: [http://www.sysresccd.org/Download Sysrescue Download]
 +
Next use LiLi (Or whatever you happen to be using) to flash the image or burn your CD. Reboot, change your boot device, and you'll find yourself at a grub menu.
  
# Emacs is primarily a text editor and not a word processor, it concentrates on manipulating any kind of text, rather than manipulating the font and look. It is client and GUI based, so can be used on local box in graphical environments with a GUI and remote on a server in a client mode.
+
Since the T series are all 64-bit laptops, make sure to boot the 64-bit kernel, as the default is 32-bit.
# Emacs provides commands for manipulate every kind of text and syntax highlighting.
+
  
=== Customizability ===
+
''But Why?: If we pick 32-bit, later on we won't be able to chroot into our Funtoo's 64-bit stage 3.''
  
'''Emacs is highly customizable:'''
+
You should see a fairly verbose boot as sysrescueCD scans for modules it requires and starts up. It is safe to simply accept prompt defaults here, unless they are errors.
  
* the <tt>customize</tt> extension, which allows settings of customized variables, such as color themes, graphical interface, etc. This part is intended for emacs beginners, who do not want to work with Emacs lisp code.
+
When you are greeted by the interactive command prompt, enter 'wizard' as prompted, and accept the default entry in the dialogue. This will give us a functioning XFCE desktop environment.
* combine keystrokes to execute complex makros.
+
* using Emacs Lisp. Designed for the emacs professional.
+
  
=== Extensibility ===
+
== Partitioning ==
 +
Partitioning is the only step of this install which provides real risk to data on other operating systems. Be extremely careful if there is something you do not wish to loose. These steps are not foolproof and may result in lost data.
  
As a result of the above points, Emacs behaviour can be easily definied to all text behavings without limit. Like some of the examples below show you:
+
Please be aware that MBR disks only support '''4''' primary partitions. You can solve this by creating an 'extended' partition and adding logical partitions to it. If you are feeling particularly brave try GPT on your disk.
  
* AUCTeX, A suite for LaTeX and other TeX versions,
+
So lets start:
* ERC, A Emacs IRC client,
+
First open up gparted. You should see it on the taskbar if you're using systemrescueCD. It will scan available drives and show you the partition table. Most users will likely find one of the following to their liking:
* ORG-mode, A Emacs PIM and Orga tool
+
* Wanderlust, A highly flexible Mail tool for Emacs
+
  
== User Configs ==
+
==== Pure Funtoo ====
=== golodhrim's config ===
+
You'll likely want:
==== .emacs ====
+
<pre>
{{File
+
/boot      :: EXT2      :: 100mb-500mb
|~/.emacs|<pre>
+
    ''Note: We choose EXT2 because there is really no good use for a journalled boot partition, but feel free to use EXT4 instead!''
;;;;;;;;;;;;;;;;;;;;;;
+
/          :: EXT4      :: 60gb (suggested floor value) - 500+
;; General Settings ;;
+
swap        :: linux-swap :: Your RAM Value (Optional, allows for hibernation)
;;;;;;;;;;;;;;;;;;;;;;
+
</pre>
 +
You may wish for a separate /home, which is perfectly legitimate, or any number of other partitions.
  
(setq emacs-root-dir (concat (getenv "HOME") "/em/"))
+
==== Dual Boot with Windows ====
 +
If dual booting with Windows, it is advisable to have Windows installed '''first''' since it will muck with the MBR and possibly want to create it's own boot partition.
 +
You'll likely want:
 +
<pre>
 +
System Reserved    :: NTFS      :: Whatever windows chooses.
 +
Windows            :: NTFS      :: >100gb (If you plan on doing any serious work on windows)
 +
/boot              :: EXT2      :: 100mb-500mb
 +
Extended Partition -
 +
  /                :: EXT4      :: Whatever is left.
 +
  swap            :: linux-swap:: Your RAM value. (Optional, allows for hibernation)
 +
</pre>
 +
You may also want a separate /home, etc. These will fit into your extended partition without contributing to MBR's 4 partition limit.
  
(setq inhibit-startup-message t)    ;; Suppress the startup message
+
== Starting the (actual) Install ==
(setq standard-indent 4)           ;; Default indent level is 3 chars
+
Up until now everything we've done has just been foreplay. Finally we can mount our partitions and get started on the installation!
(setq-default indent-tabs-mode nil) ;; Indent with spaces, not tabs
+
  
(setq make-backup-files nil)          ;; Enable backup files.
+
==== Mounting ====
(setq version-control nil)            ;; Enable versioning with default values
+
First, lets mount all of our partitions.
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))  ;; Save all backup file in this directory.
+
* Make a directory for root. Lets assume '''/mnt/funtoo'''
 +
<console>
 +
###i## mkdir /mnt/funtoo
 +
</console>
 +
* Mount your '/' partition to /mnt/funtoo
 +
<console>
 +
###i## mount /dev/sd## /mnt/funtoo
 +
</console>
 +
* Make a directory for your boot partition.
 +
<console>
 +
###i## mkdir /mnt/funtoo/boot
 +
</console>
 +
* Mount your boot partition.
 +
<console>
 +
###i## mount /dev/sd## /mnt/funtoo/boot
 +
</console>
 +
* Mount anything else you may have made and need. (Not swap)
  
(line-number-mode 1)                ;; Show line-number in the mode line
+
==== Checking the Date ====
(column-number-mode 1)              ;; Show column-number in the mode line
+
Although this may seem super un-important, if you want to avoid lots of spammy warning messages later, checking your date is beneficial.
 +
<console>
 +
###i## date
 +
</console>
 +
If it needs to be set, you'll want something like:
 +
<console>
 +
###i## date 071620002011
 +
#Fri Jul 16 20:00:00 UTC 2011
 +
</console>
  
(setq auto-fill-mode 1)            ;; Line wrap
+
==== Fetch a Stage 3 ====
 +
Next we need to fetch a tarball containing a barebones stage. We will download the core-i7 architecture version, if you have a core i5 or i3, don't worry, it's all the same.
 +
<console>
 +
###i## cd /mnt/funtoo
 +
###i## wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/corei7/stage3-current.tar.xz
 +
</console>
  
(set-default-font "Inconsolata-12")
+
Next let's unpack with:
 +
<console>
 +
###i## tar xJpf stage3-current.tar.xz
 +
</console>
 +
{{Note}} ''Seriously, don't forget the 'p' option.''
  
(setq browse-url-browser-function 'browse-url-generic
+
If you run 'ls' now, you should see the <code>/mnt/funtoo</code> is fully populated with folders such as lib, home, and proc.
      browse-url-generic-program "google-chrome")
+
  
(global-set-key (kbd "C-<prior>") 'previous-buffer)
+
==== Chroot'ing ====
(global-set-key (kbd "C-<next>" ) 'next-buffer    )
+
Now we need to change the ''apparent root'' of our system to our fledgling Funtoo system.
 +
<console>
 +
###i## cd /mnt/funtoo
 +
###i## mount --bind /proc ./proc
 +
###i## mount --bind /dev ./dev
 +
###i## cp /etc/resolv.conf ./etc
 +
###i## env -i HOME=/root TERM=$TERM chroot /mnt/funtoo /bin/bash --login
 +
</console>
  
 +
==== Getting the Portage Tree ====
 +
Funtoo (Unlike Gentoo) uses a git based portage tree, however if you're coming from Gentoo, you'll be glad to know we sync with the Gentoo tree once every 12 hours.
 +
<console>
 +
###i## emerge --sync
 +
</console>
 +
''You can ignore most of the errors that might be spat out at this stage, however if they do not disappear on subsequent merges, talk to us in #funtoo.''
 +
Your first sync will take significantly longer then subsequent syncs, as the whole tree must be synced.
  
(setq load-path (cons "~/.emacs.d/plugins" load-path))
+
==== A Configuration Celebration ====
 +
Now that we have our portage tree cloned, we need to do some initial setup on some files before doing anything else with portage.
  
(setq global-font-lock-mode 1)
+
'''Fstab'''
  
(show-paren-mode 1)
+
<console>
 +
###i## nano /etc/fstab
 +
</console>
  
;;;;;;;;;;;;;;;;;;
+
You'll want something like this: (Replace the dev values with what you are using)
;; el-get setup ;;
+
{{File
;;;;;;;;;;;;;;;;;;
+
|/etc/fstab|<pre>
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
+
# <fs> <mountpoint> <type> <opts>         <dump/pass>
(unless (require 'el-get nil t)  
+
  (with-current-buffer
+
    (url-retrieve-synchronously "https://raw.github.com/golodhrim/el-get/master/el-get-install.el")
+
  (end-of-buffer)
+
  (eval-print-last-sexp)))
+
  
(el-get 'sync)
+
/dev/sda1 /boot ext2 noauto,noatime  1 2
 +
/dev/sda3 none swap sw         0 0
 +
/dev/sda4 / ext4 noatime         0 1
 +
/dev/cdrom /mnt/cdrom auto noauto,ro         0 0
 +
</pre>}}
  
;;;;;;;;;;;;;;;
+
'''Localtime'''
;; mediawiki ;;
+
;;;;;;;;;;;;;;;
+
(require 'mediawiki)
+
  
;;;;;;;;;;;;;;;;;;;;
+
Lets remove the default localtime, and create a symbolic link to the proper time zone. (You probably will want something other then Vancouver)
;; Org-mode stuff ;;
+
<console>
;;;;;;;;;;;;;;;;;;;;
+
###i## rm /etc/localtime
 +
###i## ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime
 +
</console>
  
;; Tell emacs where org-mode is
+
''' Hostname '''
;;(setq load-path (cons "/usr/share/emacs/site-lisp/org-mode/" load-path))
+
Set your host name:
;;(setq load-path (cons "/usr/share/emacs/site-lisp/org-mode/contrib/" load-path))
+
<console>
(require 'org-install) ;; Tell emacs to use org-mode
+
###i## nano /etc/conf.d/hostname
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) ;; Turn on org-mode for all *.org files
+
</console>
  
;; Some key sequences
+
'''Hwclock'''
(define-key global-map "\C-cl" 'org-store-link)
+
(define-key global-map "\C-ca" 'org-agenda)
+
(global-set-key [f9]    'org-archive-subtree-default)
+
  
(setq org-log-done t) ;; I have no idea what this does, it was in the manual -- think it controls whether or not to log time completed for tasks
+
If you're using a dual boot system, you'll want to change this. Otherwise it's entirely optional.
 +
<console>
 +
###i## nano /etc/conf.d/hwclock
 +
</console>
  
(setq org-directory "~/notes")
+
If you're on windows you'll want:
 +
<console>
 +
###i## clock="local"
 +
</console>
  
;; Files that should be included in agenda views:
+
'''Make.conf'''
(setq org-agenda-files (list "~/notes/business.org"
+
Important enough that it deserves it's own article. A template make.conf for the T420 will be forthcoming.
                            "~/notes/personal.org"
+
                            "~/notes/projects/"
+
    "~/notes/projects/writing/"))
+
  
(setq org-todo-keywords '((type "TODO" "Postponed" "Upcoming" "Doing" "|" "DONE(#)"))) ;; TODO workflows
+
For now:
 +
If you have an i5 or i3 you will want
 +
{{File
 +
|/etc/portage/make.conf|<pre>
 +
MAKEOPTS="-j3"
 +
</pre>}}
 +
If you have an i7 you'll probably want:
 +
{{File
 +
|/etc/portage/make.conf|<pre>
 +
MAKEOPTS="-j5"
 +
</pre>}}
  
(setq org-tag-alist '(("work" . ?k) ("personal" . ?p) ("organization" . ?o) ("writing" . ?w) ("code" . ?c) ("blog" . ?b) ("funtoo" . ?f) ("social" . ?s))) ;; Most-used tags, with shortcuts
+
''But I have Hyperthreading! Why only -j3?''
 +
Hyperthreading and compiling don't play well together. You'll have the same (or better) performance with -j3 as -j5 with a dual core hyper threaded processor.
  
;; Capture stuff
+
== Stop, Kernel time! ==
(setq org-default-notes-file "~/.org/capture.org")
+
''For this guide we'll be using some pre-found config options that I will be adding later.''
(define-key global-map "\C-cc" 'org-capture)
+
(setq org-refile-targets '((org-agenda-files :level . 1)(org-agenda-files :level . 2)))
+
(setq org-refile-use-outline-path 'file)
+
  
(setq org-capture-templates
+
* Networking:
      '(("t" "Todo" entry (file+headline "~/.org/capture.org" "Tasks")
+
** iwlwifi and auxilary
            "- TODO %?\n  %i\n  %a")
+
** Unknown intel ethernet adapter. Selected several.
        ("j" "Journal" entry (file+datetree "~/.org/journal.org")
+
* GPU
            "- %?\nEntered on %U\n  %i\n  %a")))
+
** Intel available default.
 +
** nvidia will be dealt with later
  
(setq org-mobile-directory "~/Dropbox/MobileOrg")
+
Install:
(setq org-mobile-use-encryption)
+
* wpa_supplicant
(setq org-mobile-use-encryption-password "PASSWORD")
+
* iwl6000-ucode
(setq org-mobile-inbox-for-pull "~/notes/mobileorg/inbox.org")
+
* wireless-tools
  
;;;;;;;;;;;;;;;;;;;
 
;; Markdown Mode ;;
 
;;;;;;;;;;;;;;;;;;;
 
  
(require 'markdown-mode)
+
== Bootloader Setup ==
(add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode))
+
In funtoo the setup of grub is extremely simplified.
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
+
<console>
 +
###i## emerge -vqat boot-update
 +
</console>
 +
''Q: What are those options? A: We'll get to them later, lets get the system booted first, okay? ''
 +
Boot-update is a tool that will allow for very simple configuration of grub similar to older versions (But nicer still).  
  
;;;;;;;;;;;;;;;;
+
You will now edit the file <code>/etc/boot.conf</code>:
;; Python IDE ;;
+
{{File
;;;;;;;;;;;;;;;;
+
|/etc/boot.conf|<pre>
(c-add-style
+
boot {
  "python-new"
+
        generate grub
  '((indent-tabs-mode . nil)
+
        default "Funtoo Linux genkernel"
    (fill-column      . 78)
+
        timeout 3
    (c-basic-offset  . 4)
+
}
    (c-offsets-alist  . ((substatement-open . 0)
+
                          (inextern-lang    . 0)
+
                          (arglist-intro    . +)
+
                          (knr-argdecl-intro . +)))
+
    (c-hanging-braces-alist . ((brace-list-open)
+
                                (brace-list-intro)
+
                                (brace-list-close)
+
                                (brace-entry-open)
+
                                (substatement-open after)
+
                                (block-close . c-snug-do-while)))
+
    (c-block-comment-prefix . "* "))
+
)
+
  
;; This is a very crude hook that auto-selects the C style depending on
+
"Funtoo Linux" {
;; whether it finds a line starting with tab in the first 3000 characters
+
        kernel bzImage[-v]
;; in the file
+
        # params += nomodeset
(defun c-select-style ()
+
}
  (save-excursion
+
    (if (re-search-forward "^\t" 3000 t)
+
        (c-set-style "python")
+
      (c-set-style "python-new"))))
+
(add-hook 'c-mode-hook 'c-select-style)
+
  
;;;;;;;;;;;;
+
"Funtoo Linux genkernel" {
;; Django ;;
+
        kernel kernel[-v]
;;;;;;;;;;;;
+
        initrd initramfs[-v]
(yas/initialize)
+
        params += real_root=auto
(add-to-list 'load-path "~/.emacs.d/el-get/django-mode/")
+
        # params += nomodeset
(require 'django-html-mode)
+
}
(require 'django-mode)
+
</pre>}}
(yas/load-directory "~/.emacs.d/el-get/django-mode/snippets")
+
This can be configured (We'll touch on this later. We need to make sure the kernel is booting and working before we start tweaking) with options for the kernel.
(add-to-list 'auto-mode-alist '("\\.djhtml$" . django-html-mode))
+
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
==== Dual-Booters Only ====
;; Document Engineering (AUCTeX + ConTeXt) ;;
+
If you want to dual boot with windows you'll need to add an entry here:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
{{File
(load "auctex.el" nil t t)
+
|/etc/boot.conf|<pre>
(load "preview-latex.el" nil t t)
+
<pre>
 +
"Windows 7" {
 +
    type win7
 +
    params root=/dev/sda1
 +
}
 +
</pre>}}
 +
==== Installing Grub onto the Drive(Everyone) ====
 +
Next we can install grub onto the drive.
 +
<console>
 +
###i## grub-install --no-floppy /dev/sda
 +
###i## boot-update
 +
</console>
 +
No errors means we should be good to go!
  
(setq TeX-auto-save 1)
+
== Tidy up and go. ==
(setq TeX-parse-self 1)
+
Just a few more things!
(setq TeX-auto-untabify 1)
+
(setq TeX-display-help 1)
+
(setq TeX-save-query nil)
+
(setq TeX-clean-confirm nil)
+
(setq-default TeX-master nil)
+
  
(add-hook 'TeX-mode-hook (lambda () (TeX-fold-mode 1)))
+
Lets set a root password.
(add-hook 'TeX-mode-hook (lambda () (TeX-source-specials-mode 1)))
+
<console>
(add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-bad-boxes)))
+
###i## passwd
(add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-warnings)))
+
</console>
(add-hook 'TeX-mode-hook (lambda () (outline-minor-mode)))
+
(add-hook 'TeX-mode-hook (lambda () (abbrev-mode t)))
+
(add-hook 'TeX-mode-hook (lambda () (auto-fill-mode 1)))
+
  
(add-hook 'TeX-mode-hook 'LaTeX-math-mode)
+
It is advisable to exit the chroot and umount all the relevant install drives. Or at least just exit the chroot, but you can just simply reboot from here.
 +
<console>
 +
###i## exit
 +
###i## cd /
 +
###i## umount /mnt/funtoo/boot /mnt/funtoo/dev /mnt/funtoo/proc /mnt/funtoo
 +
###i## reboot
 +
</console>
  
(autoload 'etexshow "etexshow" "Browser for ConTeXt commands." t)
+
== Configuring the New System ==
 +
Welcome to funtoo! You should be greeted by a bunch of spammy text that scrolls by reasonably fast and then a couple penguins and openrc. Login to your root user and lets start playing.
  
(setq etexshow-xml-files-alist
+
A note, this part of the guide is meant to be much more of a dialogue between us.
  `((,(concat emacs-root-dir "libs/etexshow/cont-en.xml") .
+
      ,(concat "/tmp/cont-en.cache"))))
+
  
(setq etexshow-comment-file
+
==== Getting up the (wired) network ====
  (concat emacs-root-dir "libs/etexshow/cont-en-comments.xml"))
+
If you're gifted with a wired network connect, use it! The initial setup is much more convenient and quick.
  
(setq TeX-PDF-mode 1)
+
Quickly set up the network with
(setq revert-without-query '(".+pdf$"))
+
<console>
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
+
###i## /etc/init.d/dhcpcd start
 +
</console>
 +
Now check to see if our wired adapter is listed with ifconfig.
 +
<console>
 +
###i## ifconfig
 +
(or)
 +
###i## ping google.com
 +
</console>
 +
If you see it listed with a description, we're good to go!
  
;;;;;;;;;;
+
==== Editing the make.conf ====
;; bbdb ;;
+
Before we start merging into our tree everything under the sun, lets do some system planning.
;;;;;;;;;;
+
(setq bbdb-file "~/.emacs.d/.bbdb")
+
(require 'bbdb)
+
(bbdb-initialize)
+
(setq
+
bbdb-offer-save 1                        ;; 1 means save-without-asking
+
bbdb-use-pop-up t                        ;; allow popups for addresses
+
bbdb-electric-p t                        ;; be disposable with SPC
+
bbdb-popup-target-lines 1                ;; very small
+
bbdb-dwim-net-address-allow-redundancy t  ;; always use full name
+
bbdb-quiet-about-name-mismatches 2        ;; show name-mismatches 2 secs
+
bbdb-always-add-address t                ;; add new addresses to existing...
+
                                          ;; ...contacts automatically
+
bbdb-canonicalize-redundant-nets-p t      ;; x@foo.bar.cx => x@bar.cx
+
bbdb-completion-type nil                  ;; complete on anything
+
bbdb-complete-name-allow-cycling t        ;; cycle through matches
+
                                          ;; this only works partially
+
bbdb-message-caching-enabled t            ;; be fast
+
bbdb-use-alternate-names t                ;; use AKA
+
bbdb-elided-display t                    ;; single-line addresses
+
;; auto-create addresses from mail
+
bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook
+
bbdb-ignore-some-messages-alist          ;; don't ask about fake addresses
+
;; NOTE: there can be only one entry per header (such as To, From)
+
;; http://flex.ee.uec.ac.jp/texi/bbdb/bbdb_11.html
+
'(( "From" . "no.?reply\\|DAEMON\\|daemon\\|facebookmail\\|twitter")))
+
  
;;;;;;;;;;;;;;;;;
+
You can use this as a starting point:
;; Jabber Mode ;;
+
{{File
;;;;;;;;;;;;;;;;;
+
|/etc/portage/make.conf|<pre>
 +
# These settings were set by the metro build script that automatically built this stage.
 +
# Please consult /etc/make.conf.example for a more detailed example.
  
(require 'jabber-autoloads)
+
ACCEPT_KEYWORDS="~amd64"
(setq jabber-account-list '(
+
CHOST="x86_64-pc-linux-gnu"
                            ("USER@jabber-server.tld"
+
CFLAGS="-march=corei7 -O2 -pipe"
                            (:password . "PASSWORD")
+
CXXFLAGS="-march=corei7 -O2 -pipe"
                            )
+
SYNC="git://github.com/funtoo/ports-2012.git"
                          )
+
)
+
(setq
+
    jabber-history-enabled t
+
    jabber-use-global-history nil
+
    jabber-backlog-number 40
+
    jabber-backlog-days 30
+
)
+
  
(add-hook 'jabber-chat-mode-hook 'goto-address)
+
# -j3 :: Have make use 3 threads by default.
 +
MAKEOPTS="-j3"
 +
#  Setup emerge's default options:
 +
#    --ask    :: Double check before merging.
 +
#    --verbose :: Show use flags etc.
 +
#    --quiet  :: Don't show me make spam.
 +
#    --tree    :: Use nice dependancy graphs.
 +
EMERGE_DEFAULT_OPTS="--ask --verbose --quiet --tree"
  
(load "~/.emacs.d/plugins/autosmiley.el")
+
# Portage Features
(require 'autosmiley)
+
#    TODO: Descriptions
(add-hook 'jabber-chat-mode-hook 'autosmiley-mode)
+
FEATURES="mini-manifest parallel-fetch userfetch parallel-install sandbox fixpackages collision-protect"
  
(defvar libnotify-program "/usr/bin/notify-send")
+
#  We might use binary packages later. Lets set that up just in case.
 +
PORTAGE_BINHOST=/usr/portage/packages
  
(defun notify-send (title message)
 
  (start-process "notify" " notify"
 
                libnotify-program "--expire-time=4000" title message))
 
  
(defun libnotify-jabber-notify (from buf text proposed-alert)
+
# CCache
   "(jabber.el hook) Notify of new Jabber chat messages via libnotify"
+
#   This is not going to be done by default.
   (when (or jabber-message-alert-same-buffer
+
#   Why? It's only wortwhile if you plan on compiling packages multiple
                        (not (memq (selected-window) (get-buffer-window-list buf))))
+
#  times per version, which the average user will not.
    (if (jabber-muc-sender-p from)
+
#CCACHE_SIZE="5G"
        (notify-send (format "(PM) %s"
+
#CCACHE_DIR="/var/cache/ccache"
                            (jabber-jid-displayname (jabber-jid-user from)))
+
                    (format "%s: %s" (jabber-jid-resource from) text)))
+
    (notify-send (format "%s" (jabber-jid-displayname from))
+
                text)))
+
  
(add-hook 'jabber-alert-message-hooks 'libnotify-jabber-notify)
+
# Licenses
 +
#  By default we're just going to accept everything.
 +
ACCEPT_LICENSE="*"
  
(defun jabber-visit-history (jid)
 
  "Visit jabber history with JID in a new buffer.
 
  
Performs well only for small files. Expect to wait a few seconds
+
# Device Specific Settings
for large histories. Adapted from `jabber-chat-create-buffer'."
+
#    INPUT_DEVICES :: A list of input devices you'll be wanting. This is needed for xorg and not much else.
  (interactive (list (jabber-read-jid-completing "JID: ")))
+
INPUT_DEVICES="evdev synaptics"
   (let ((buffer (generate-new-buffer (format "*-jabber-history-%s-*"
+
#    VIDEO CARDS   :: A list of video cards. Optimus users beware here.
                                            (jabber-jid-displayname jid)))))
+
VIDEO_CARDS="intel i915 i965 nvidia"
    (switch-to-buffer buffer)
+
    (make-local-variable 'jabber-chat-ewoc)
+
    (setq jabber-chat-ewoc (ewoc-create #'jabber-chat-pp))
+
    (mapc 'jabber-chat-insert-backlog-entry
+
          (nreverse (jabber-history-query nil nil t t "."
+
                                          (jabber-history-filename jid))))
+
    (view-mode)))
+
  
;;;;;;;;;;
+
# Use flags.
;; EMMS ;;
+
#  Application specific flags should be migrated to /etc/portage/package.use (which can be a folder with multiple files!)
;;;;;;;;;;
+
#  To look at the user flags for an application use "equery uses FOOPKG"
(require 'emms-setup)
+
USE="
(emms-devel)
+
acpi alsa /
(emms-default-players)
+
bash-completition /
 +
curl /
 +
dvdr /
 +
ithreads /
 +
ncurses networkmanager/
 +
policykit /
 +
ssl sse sse2 sse3 sse4 /
 +
threads /
 +
udev /
 +
vim-syntax /
 +
zsh-completion /
 +
"
 +
</pre>}}
  
;;;;;;;;;
+
=== Installing an Editor ===
;; ERC ;;
+
Well, first things first lets get ourselves an editor. The author prefers vim, but you may like emacs or something else... Feel free to disregard this and explore! If you plan to have multiple users however, this will often be expected by experienced linux users.
;;;;;;;;;
+
(require 'erc)
+
(require 'erc-extension)
+
(require 'erc-services)
+
(require 'erc-tex)
+
(require 'tls)
+
(require 'erc-nicklist)
+
  
(and
+
<console>
(require 'erc-highlight-nicknames)
+
###i## emerge vim
(add-to-list 'erc-modules 'highlight-nicknames)
+
</console>
(erc-update-modules))
+
Check that your USE flags look reasonable (see above) and feel free to do any fine tweaking in /etc/portage/package.use.
 +
Consult your output after merge! You may want to follow some of it's advice.
  
(erc-services-mode 1)
+
You can find multiple good guides on google for vim configurations and setups.
 +
Funtoo also provides a very nice base configuration in /etc/vim/vimrc.
  
(setq tls-program '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof
+
==== Boot Parameters ====
                            -CAfile /home/USER/.ssl/USER.pem
+
The T420 has a number of boot parameters that can be set to conserve power. On a laptop these options are generally reasonable:
                            -cert /home/USER/.ssl/USER.pem"
+
<pre>
                    "gnutls-cli --priority secure256
+
$ cat /etc/boot.conf
                                --x509cafile /home/USER/.ssl/USER.pem
+
boot {
                                --x509certfile /home/USER/.ssl/USER.pem -p %p %h"
+
generate grub
                    "gnutls-cli --priority secure256 -p %p %h"))
+
default "Funtoo Linux"  
 +
timeout 15
 +
}
  
(autoload 'erc-nick-notify-mode "erc-nick-notify" "Minor mode that calls `erc-nick-notify-cmd' when his nick gets mentioned in an erc channel" t)
+
"Funtoo Linux" {
(eval-after-load 'erc '(erc-nick-notify-mode t))
+
kernel bzImage[-v]
(defun irc-erc ()
+
#  Force PCIE Active State Power Management on.
  "Fire up IRC."
+
params += pcie_aspm=force
   (interactive)
+
#  TODO (Range 1..15)
   (erc-tls :server "chat.freenode.net" :port 7000 :nick "USER" :full-name "FULL NAME" :password "PASSWORD"))
+
params += epb=7
 +
#  TODO
 +
params += hpet=force
 +
#  i915 Enable rc6 sleep state (?)
 +
params += i915.i915_enable_rc6=1
 +
#   TODO (Framebuffer?)
 +
params += i915.i915_enable_fbc=1
 +
#   Downclock the lvds screen (60hz -> 50hz)
 +
params += i915.lvds_downclock=1
 +
        #  Quiet some of the excessively verbose kernel boot
 +
        params += quiet
 +
}
  
(setq erc-autojoin-channels-alist '(("freenode.net" "#frogandowl" "#funtoo" "#funtoo-quebec" "#syntazia" "#context" "#nginx" "#emacs" "#openvswitch")))
+
"Windows 7" {
(setq erc-log-channels-directory "~/.erc/logs/")
+
        type win7
(setq erc-log-insert-log-on-open nil)
+
        params root=/dev/sda1
(setq erc-save-buffer-on-part nil
+
}
      erc-save-buffer-queries-on-quit nil
+
      erc-log-write-after-send t
+
      erc-log-write-after-insert t)
+
  
(require 'smiley)
+
#"Funtoo Linux genkernel" {
    (add-to-list 'smiley-regexp-alist '("\\(:-?]\\)\\W" 1 "forced"))
+
# kernel kernel[-v]
    (add-to-list 'smiley-regexp-alist '("\\s-\\(:-?/\\)\\W" 1 "wry"))
+
# initrd initramfs[-v]
    (add-to-list 'smiley-regexp-alist '("\\(:-?(\\)\\W" 1 "sad"))
+
# params += real_root=auto
    (add-to-list 'smiley-regexp-alist '("\\((-?:\\)\\W" 1 "reverse-smile"))
+
#}
    (add-to-list 'smiley-regexp-alist '("\\(:-?D\\)\\W" 1 "grin"))
+
</pre>
    (add-to-list 'smiley-regexp-alist '("\\(:-?P\\)\\W" 1 "poke"))
+
  
;; (setq smiley-cached-regexp-alist nil)
+
When you're done, update grub with
;; (smiley-update-cache)
+
<pre>
 +
boot-update
 +
</pre>
  
;;;;;;;;;;;;;;;;
+
==== Power Saving Local Scripts ====
;; Wanderlust ;;
+
Next we're going to set up a script that runs at default runlevel for the machine. This will echo several options to various dev files. Most distros would do this via /etc/rc.local or something of the like.
;;;;;;;;;;;;;;;;
+
(autoload 'wl "wl" "Wanderlust" t)
+
  
;;;;;;;;;;;;;;;
+
With Funtoo (and Gentoo) this is accomplished via
;; mailcrypt ;;
+
<pre>
;;;;;;;;;;;;;;;
+
/etc/local.d
(require 'mailcrypt)
+
</pre>
(add-hook 'wl-summary-mode-hook 'mc-install-read-mode)
+
Consult the README (in directory) for more information.
(add-hook 'wl-mail-setup-hook 'mc-install-write-mode)
+
  
(defun mc-wl-verify-signature ()
+
<pre>
  (interactive)
+
$ cat /etc/local.d/power-saving.start
  (save-window-excursion
+
# /bin/bash
     (wl-summary-jump-to-current-message)
+
#
     (mc-verify)))
+
echo 1 > /sys/modules/snd_hda_intel/parameters/power_save
 +
for i in /sys/bus/usb/devices/*/power/autosuspend; do
 +
     echo 1 > $i
 +
done
 +
for i in /sys/class/scsi_host/host*/link_power_management_policy; do
 +
     echo min_power > $i
 +
done
 +
</pre>
 +
If you copy this wholesale remember to chmod -x the file!
  
(defun mc-wl-decrypt-message ()
+
==== rc.conf ====
  (interactive)
+
rc.conf lets us change some options to do with open RC.
  (save-window-excursion
+
    (wl-summary-jump-to-current-message)
+
    (let ((inhibit-read-only t))
+
      (mc-decrypt))))
+
  
(eval-after-load "mailcrypt"
+
First, lets set rc_sys to it's default, this will suppress a warning message at boot.
  '(setq mc-modes-alist
+
<pre>
        (append
+
rc_sys=""
          (quote
+
</pre>
          ((wl-draft-mode (encrypt . mc-encrypt-message)
+
                          (sign . mc-sign-message))
+
            (wl-summary-mode (decrypt . mc-wl-decrypt-message)
+
                            (verify . mc-wl-verify-signature))))
+
          mc-modes-alist)))
+
  
;;;;;;;;;;;;;;;;;;;;;
+
Next, we can turn on rc_parallel to get a bit of speedup on boot.
;; notify function ;;
+
<pre>
;;;;;;;;;;;;;;;;;;;;;
+
rc_parallel="YES"
(defun djcb-popup (title msg &optional icon sound)
+
</pre>
  "Show a popup if we're on X, or echo it otherwise; TITLE is the title of the message, MSG is the context. Optionally, you can provide an ICON and a sound to be played"
+
If you get errors or problems with services on boot, try turning this off.
  (interactive)
+
  (when sound (shell-command
+
              (concat "mplayer2 -really-quiet " sound " 2> /dev/null")))
+
  (if (eq window-system 'x)
+
      (shell-command (concat "notify-send "
+
                           
+
                            (if icon (concat "-i " icon) "")
+
                            " '" title "' '" msg "'"))
+
    ;; text only version
+
    (message (concat title ": " msg))))
+
  
;; the appointment notification facility
+
== Making it Usable ==
(setq
+
Next we'll be setting up a normal user and installing the venerable Xorg.
appt-message-warning-time 15 ;; warn 15 min in advance
+
appt-display-mode-line t    ;; show in the modeline
+
appt-display-format 'window) ;; usr our func
+
(appt-activate t)            ;; active appt (appointment notification)
+
(display-time)
+
  
;; update appt each time agenda opened
+
==== Mouse in framebuffer ====
(add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt)
+
Right now we should be looking at a framebuffer'd console.
 +
<pre>
 +
/etc/init.d/gpm start
 +
</pre>
 +
gpm is a daemon that allows us to use our mouse (trackpad/trackpoint) on console. Give it a try! If you want to keep it on across boots, add it to your init.
 +
<pre>
 +
rc-update add gpm default
 +
</pre>
  
;; our little facade-function for djcb-popup
+
==== Making a New User =====
(defun djcb-appt-display (min-to-app new-time msg)
+
Lets use superadduser to make the task ever so much easier (Though, it is already easy)
  (djcb-popup (format "Appointment in %s minute(s)" min-to-app) msg
+
<pre>
              "/usr/share/icons/gnome/32x32/status/appointment-soon.png"
+
emerge superadduser
              "/usr/share/sounds/purple/alert.wav"))
+
superadduser
(setq appt-disp-window-function (function djcb-appt-display))
+
</pre>
  
;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Walk through the prompts and set up your user how you choose.
;; Custom Variable sets ;;
+
;;;;;;;;;;;;;;;;;;;;;;;;;;
+
(custom-set-variables
+
  ;; custom-set-variables was added by Custom.
+
  ;; If you edit it by hand, you could mess it up, so be careful.
+
  ;; Your init file should contain only one such instance.
+
  ;; If there is more than one, they won't work right.
+
'(TeX-command-list (quote (("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode texinfo-mode ams-tex-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("Makeinfo" "makeinfo %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with Info output") ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with HTML output") ("AmSTeX" "%(PDF)amstex %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX") ("ConTeXt MKIV" "context %t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt MKIV") ("ConTeXt" "texexec --once --texutil %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("File" "%(o?)dvips %d -o %f " TeX-run-command t t :help "Generate PostScript file") ("Index" "makeindex %s" TeX-run-command nil t :help "Create index file") ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for correctness") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command"))))
+
'(column-number-mode t)
+
'(erc-modules (quote (autojoin bbdb button completion fill irccontrols list log match menu move-to-prompt netsplit networks noncommands readonly ring services smiley stamp spelling track)))
+
'(mediawiki-site-alist (quote (("Funtoo" "http://www.funtoo.org/" "USER" "PASSWORD" "")))))
+
(custom-set-faces
+
  ;; custom-set-faces was added by Custom.
+
  ;; If you edit it by hand, you could mess it up, so be careful.
+
  ;; Your init file should contain only one such instance.
+
  ;; If there is more than one, they won't work right.
+
)
+
  
;;;;;;;;;;;;;;;;;;
+
==== Sudo Make Me a Sandwich ====
;; Color-Themes ;;
+
Next lets merge in sudo, and set up our new user to be able to use sudo.
;;;;;;;;;;;;;;;;;;
+
<pre>
;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/color-theme/color-theme.el")
+
emerge sudo
;;(add-to-list 'load-path "~/.emacs.d/themes/")
+
</pre>
(require 'color-theme)
+
Now edit the config with
(color-theme-initialize)
+
<pre>
;;(color-theme-subtle-hacker)
+
visudo
(color-theme-twilight)
+
</pre>
;;(eval-after-load "color-theme"
+
You'll probably want to uncomment out one of the two options:
;;  '(progn
+
<pre>
;;    (color-theme-initialize)
+
## Uncomment to allow members of group wheel to execute any command
;;    (require 'color-theme-citrus)
+
# %wheel ALL=(ALL) ALL
;;    (require 'color-theme-candy)
+
;;    (require 'color-theme-autumn-leaves)
+
;;    (require 'color-theme-inthedark)
+
;;    (require 'color-theme-marine)
+
;;    (require 'color-theme-october)
+
;;    (require 'color-theme-eatyourgreens)
+
;;    (require 'color-theme-august)
+
;;    (require 'color-theme-saddle-2)
+
;;    (color-theme-saddle-2)))
+
;;    (color-theme-subtle-hacker)))
+
  
(setq css-indent-offset 2)
+
## Same thing without a password
</pre>}}
+
# %wheel ALL=(ALL) NOPASSWD: ALL
 
+
</pre>
==== .wl ====
+
<console>
+
###i## nano ~/.wl
+
;; load bbdb support
+
(require 'bbdb-wl)
+
(bbdb-wl-setup)
+
  
;; setup from where to get addresses
+
Now just add your user to the 'wheel' group.
(setq bbdb-wl-folder-regexp "^\.INBOX|^\.inbox|^\.Sent|^\.sent|^\.\[IMAPS\]\\Sent")
+
<pre>
 +
gpasswd -a foouser wheel
 +
exit
 +
</pre>
 +
Now re-login as your user, and you should be good to go!
  
;; define keybinding
+
==== Tmux ====
(define-key wl-draft-mode-map (kbd "<C-tab>") 'bbdb-complete-name)
+
Before we emerge xorg, lets get tmux working so we can easily scroll through output and look at USE flags etc.
 +
<pre>
 +
emerge tmux
 +
</pre>
 +
The default config will suffice for now. You may find it beneficial to learn to use tmux ''properly'' sometime, but for now we'll hold hands.
  
;; set multiple e-mail addresses
+
<pre>
(setq wl-user-mail-address-list (quote ("User@googlemail.com" "USER@own-server.tld")))
+
tmux
 +
</pre>
 +
Now we can scroll through output with CTRL+B [ and the up and down arrows.
  
;; handle ("d") mark
+
== Xorg ==
;; remove = instant removal (same as "D"), thrash = move to wl-trash-folder
+
Xorg is a large topic in and on itself. We'll focus on getting a working xorg and a simple window manager.
;; string = move to string
+
(setq wl-dispose-folder-alist
+
      '(
+
        ("\.\*googlemail\\.com" "%[Imap]/Trash:"User@googlemail.com"/clear@imap.gmail.com:993!")
+
        ("\.\*@own\-\server\\.tld" "%INBOX.Trash:"USER"/clear@imap.own-server.tld")
+
))
+
  
;; notify hook
+
<pre>
(add-hook 'wl-biff-notify-hook
+
# (in tmux)
          (lambda()
+
sudo emerge xorg-server
            (djcb-popup "Wanderlust" "You have new mail!"
+
</pre>
                        "/usr/share/icons/gnome/32x32/status/mail-unread.png"
+
Once again use CTRL+B [ to start scrolling (escape to exit) and look through your use flags, adding anything you might want.
                        "/usr/share/sounds/purple/alert.wav")))
+
  
;; timer settings
+
== A note on Gnome ==
(setq
+
Want to get rid of that awful lock screen on wake from suspend?
wl-biff-check-interval 30 ;; check every 30 seconds
+
<pre>gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true'</pre>
wl-biff-use-idle-timer t) ;; in the background
+
 
+
;; Name of top-folder, default "Desktop"
+
(setq wl-folder-desktop-name "e-Mail")
+
 
+
;; select correct email address when we _start_ writing a draft.
+
(add-hook 'wl-mail-setup-hook 'wl-draft-config-exec)
+
 
+
(setq wl-draft-config-alist
+
      '(
+
        ((string-match "googlemail.com" wl-draft-parent-folder)
+
        (template . "User"))
+
        ((string-match "own-server.tld" wl-draft-parent-folder)
+
        (template . "USER"))
+
))
+
 
+
;; choose template with C-c C-j
+
(setq wl-template-alist
+
      '(("User"
+
        (wl-from . "Full Name <User@googlemail.com>")
+
        ("From" . wl-from)
+
        (wl-smtp-posting-user . "User")
+
        (wl-smtp-posting-server . "smtp.gmail.com")
+
        (wl-smtp-authenticate-type . "plain")
+
        (wl-smtp-connection-type . 'starttls)
+
        (wl-smtp-posting-port . 587)
+
        (wl-local-domain . "googlemail.com")
+
        (wl-message-id-domain . "smtp.gmail.com")
+
       
+
        (wl-fcc .  "%[IMAPS]/Sent:\"User@googlemail.com\"/clear@imap.gmail.com:993!")
+
        (wl-draft-folder .  "%[IMAPS]/Draft:\"User@googlemail.com\"/clear@imap.gmail.com:993!")
+
        )
+
        ("USER"
+
        (wl-from  . "Full Name <USER@own-server.tld>")
+
        ("From"  . wl-from)
+
        (wl-smtp-posting-user  . "USER")
+
        (wl-smtp-posting-server  . "smtp.own-server.tld")
+
        (wl-local-domain . "own-server.tld")
+
       
+
        (wl-fcc  "%INBOX.Sent:USER/digest-md5@imap.own-server.tld:143")
+
        (wl-draft-folder  "%INBOX.Drafts:USER/digest-md5@imap.own-server.tld:143")
+
        )
+
      )
+
)
+
 
+
(define-key wl-template-mode-map (kbd "<right>") 'wl-template-next)
+
(define-key wl-template-mode-map (kbd "<left>") 'wl-template-prev)
+
 
+
(setq wl-default-spec "%")
+
 
+
(setq wl-fcc-force-as-read t)
+
(setq wl-auto-save-drafts-interval nil)
+
</console>
+
 
+
==== .folders ====
+
<console>
+
###i## nano ~/.folders
+
User@googlemail{
+
        %INBOX:"User@googlemail.com"/clear@imap.gmail.com:993!    "Inbox"
+
        [IMAPS-gmail]{
+
                %[IMAPS]/Sent:"User@googlemail.com"/clear@imap.gmail.com:993!      "Sent"
+
                %[IMAPS]/Draft:"User@googlemail.com"/clear@imap.gmail.com:993!      "Draft"
+
                %[IMAPS]/Spam:"User@googlemail.com"/clear@imap.gmail.com:993!      "Spam"
+
                %[IMAPS]/Trash:"User@googlemail.com"/clear@imap.gmail.com:993!      "Trash"
+
        }
+
}
+
USER@own-server.tld{
+
        %INBOX:USER/digest-md5@imap.own-server.tld  "Inbox"
+
        %INBOX.Sent:USER/digest-md5@imap.own-server.tld "Sent"
+
        %INBOX.Drafts:USER/digest-md5@imap.own-server.tld "Drafts"
+
}
+
</console>
+
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
[[Category:Featured]]
+
[[Category:HWLaptop]]
 +
[[Category:Hardware Compatibility]]

Revision as of 20:41, 17 January 2014

Introduction

Throughout, this article will assume the following:

  • You have installed Gentoo or Funtoo in the past.
    • If you haven't, this article will still serve you well, but please have either the official funtoo, or gentoo install guides open. We move through non-machine-specific bits with little elaboration.
  • Have a T420 or similar machine.

Even if you do not have a T420, you may find this guide useful for:

  • Nvidia Optimus Cards.
  • Power management.
  • General setup.

This installation assumes (For now) that the install is starting from an MS-Windows installation. If you are not on Windows, please add your favourite choice of steps, keep the emphasis on ease of understanding.

Getting Started

You'll want to get yourself running off a LiveCD or LiveUSB to start. This guide will assume liveUSB, since some users find them more difficult to prepare, this is usually due to boot flag issues. (Note: Live USB restore drives are nice to have in general! The author keeps one in his college binder.)

Windows

We can use LiLi for this, it provides a nice, simple interface and is fairly reliable: LiLi Download

SysrescueCD

Grab the version that Suites your needs here: Sysrescue Download Next use LiLi (Or whatever you happen to be using) to flash the image or burn your CD. Reboot, change your boot device, and you'll find yourself at a grub menu.

Since the T series are all 64-bit laptops, make sure to boot the 64-bit kernel, as the default is 32-bit.

But Why?: If we pick 32-bit, later on we won't be able to chroot into our Funtoo's 64-bit stage 3.

You should see a fairly verbose boot as sysrescueCD scans for modules it requires and starts up. It is safe to simply accept prompt defaults here, unless they are errors.

When you are greeted by the interactive command prompt, enter 'wizard' as prompted, and accept the default entry in the dialogue. This will give us a functioning XFCE desktop environment.

Partitioning

Partitioning is the only step of this install which provides real risk to data on other operating systems. Be extremely careful if there is something you do not wish to loose. These steps are not foolproof and may result in lost data.

Please be aware that MBR disks only support 4 primary partitions. You can solve this by creating an 'extended' partition and adding logical partitions to it. If you are feeling particularly brave try GPT on your disk.

So lets start: First open up gparted. You should see it on the taskbar if you're using systemrescueCD. It will scan available drives and show you the partition table. Most users will likely find one of the following to their liking:

Pure Funtoo

You'll likely want:

/boot       :: EXT2       :: 100mb-500mb
    ''Note: We choose EXT2 because there is really no good use for a journalled boot partition, but feel free to use EXT4 instead!''
/           :: EXT4       :: 60gb (suggested floor value) - 500+
swap        :: linux-swap :: Your RAM Value (Optional, allows for hibernation)

You may wish for a separate /home, which is perfectly legitimate, or any number of other partitions.

Dual Boot with Windows

If dual booting with Windows, it is advisable to have Windows installed first since it will muck with the MBR and possibly want to create it's own boot partition. You'll likely want:

System Reserved    :: NTFS      :: Whatever windows chooses.
Windows            :: NTFS      :: >100gb (If you plan on doing any serious work on windows)
/boot              :: EXT2      :: 100mb-500mb
Extended Partition -
  /                :: EXT4      :: Whatever is left.
  swap             :: linux-swap:: Your RAM value. (Optional, allows for hibernation)

You may also want a separate /home, etc. These will fit into your extended partition without contributing to MBR's 4 partition limit.

Starting the (actual) Install

Up until now everything we've done has just been foreplay. Finally we can mount our partitions and get started on the installation!

Mounting

First, lets mount all of our partitions.

  • Make a directory for root. Lets assume /mnt/funtoo
# mkdir /mnt/funtoo
  • Mount your '/' partition to /mnt/funtoo
# mount /dev/sd## /mnt/funtoo
  • Make a directory for your boot partition.
# mkdir /mnt/funtoo/boot
  • Mount your boot partition.
# mount /dev/sd## /mnt/funtoo/boot
  • Mount anything else you may have made and need. (Not swap)

Checking the Date

Although this may seem super un-important, if you want to avoid lots of spammy warning messages later, checking your date is beneficial.

# date

If it needs to be set, you'll want something like:

# date 071620002011
#Fri Jul 16 20:00:00 UTC 2011

Fetch a Stage 3

Next we need to fetch a tarball containing a barebones stage. We will download the core-i7 architecture version, if you have a core i5 or i3, don't worry, it's all the same.

# cd /mnt/funtoo
# wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/corei7/stage3-current.tar.xz

Next let's unpack with:

# tar xJpf stage3-current.tar.xz

Note

{{{1}}}

Seriously, don't forget the 'p' option.

If you run 'ls' now, you should see the /mnt/funtoo is fully populated with folders such as lib, home, and proc.

Chroot'ing

Now we need to change the apparent root of our system to our fledgling Funtoo system.

# cd /mnt/funtoo
# mount --bind /proc ./proc
# mount --bind /dev ./dev
# cp /etc/resolv.conf ./etc
# env -i HOME=/root TERM=$TERM chroot /mnt/funtoo /bin/bash --login

Getting the Portage Tree

Funtoo (Unlike Gentoo) uses a git based portage tree, however if you're coming from Gentoo, you'll be glad to know we sync with the Gentoo tree once every 12 hours.

# emerge --sync

You can ignore most of the errors that might be spat out at this stage, however if they do not disappear on subsequent merges, talk to us in #funtoo. Your first sync will take significantly longer then subsequent syncs, as the whole tree must be synced.

A Configuration Celebration

Now that we have our portage tree cloned, we need to do some initial setup on some files before doing anything else with portage.

Fstab

# nano /etc/fstab

You'll want something like this: (Replace the dev values with what you are using)

{{{name}}}
{{{body}}}

Localtime

Lets remove the default localtime, and create a symbolic link to the proper time zone. (You probably will want something other then Vancouver)

# rm /etc/localtime
# ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime

Hostname Set your host name:

# nano /etc/conf.d/hostname

Hwclock

If you're using a dual boot system, you'll want to change this. Otherwise it's entirely optional.

# nano /etc/conf.d/hwclock

If you're on windows you'll want:

# clock="local"

Make.conf Important enough that it deserves it's own article. A template make.conf for the T420 will be forthcoming.

For now: If you have an i5 or i3 you will want

{{{name}}}
{{{body}}}

If you have an i7 you'll probably want:

{{{name}}}
{{{body}}}

But I have Hyperthreading! Why only -j3? Hyperthreading and compiling don't play well together. You'll have the same (or better) performance with -j3 as -j5 with a dual core hyper threaded processor.

Stop, Kernel time!

For this guide we'll be using some pre-found config options that I will be adding later.

  • Networking:
    • iwlwifi and auxilary
    • Unknown intel ethernet adapter. Selected several.
  • GPU
    • Intel available default.
    • nvidia will be dealt with later

Install:

  • wpa_supplicant
  • iwl6000-ucode
  • wireless-tools


Bootloader Setup

In funtoo the setup of grub is extremely simplified.

# emerge -vqat boot-update

Q: What are those options? A: We'll get to them later, lets get the system booted first, okay? Boot-update is a tool that will allow for very simple configuration of grub similar to older versions (But nicer still).

You will now edit the file /etc/boot.conf:

{{{name}}}
{{{body}}}

This can be configured (We'll touch on this later. We need to make sure the kernel is booting and working before we start tweaking) with options for the kernel.

Dual-Booters Only

If you want to dual boot with windows you'll need to add an entry here:

{{{name}}}
{{{body}}}

Installing Grub onto the Drive(Everyone)

Next we can install grub onto the drive.

# grub-install --no-floppy /dev/sda
# boot-update

No errors means we should be good to go!

Tidy up and go.

Just a few more things!

Lets set a root password.

# passwd

It is advisable to exit the chroot and umount all the relevant install drives. Or at least just exit the chroot, but you can just simply reboot from here.

# exit
# cd /
# umount /mnt/funtoo/boot /mnt/funtoo/dev /mnt/funtoo/proc /mnt/funtoo
# reboot

Configuring the New System

Welcome to funtoo! You should be greeted by a bunch of spammy text that scrolls by reasonably fast and then a couple penguins and openrc. Login to your root user and lets start playing.

A note, this part of the guide is meant to be much more of a dialogue between us.

Getting up the (wired) network

If you're gifted with a wired network connect, use it! The initial setup is much more convenient and quick.

Quickly set up the network with

# /etc/init.d/dhcpcd start

Now check to see if our wired adapter is listed with ifconfig.

# ifconfig
#  (or)
# ping google.com

If you see it listed with a description, we're good to go!

Editing the make.conf

Before we start merging into our tree everything under the sun, lets do some system planning.

You can use this as a starting point:

{{{name}}}
{{{body}}}

Installing an Editor

Well, first things first lets get ourselves an editor. The author prefers vim, but you may like emacs or something else... Feel free to disregard this and explore! If you plan to have multiple users however, this will often be expected by experienced linux users.

# emerge vim

Check that your USE flags look reasonable (see above) and feel free to do any fine tweaking in /etc/portage/package.use. Consult your output after merge! You may want to follow some of it's advice.

You can find multiple good guides on google for vim configurations and setups. Funtoo also provides a very nice base configuration in /etc/vim/vimrc.

Boot Parameters

The T420 has a number of boot parameters that can be set to conserve power. On a laptop these options are generally reasonable:

$ cat /etc/boot.conf
boot {
	generate grub
	default "Funtoo Linux" 
	timeout 15 
}

"Funtoo Linux" {
	kernel bzImage[-v]
	#   Force PCIE Active State Power Management on.
	params += pcie_aspm=force
	#   TODO (Range 1..15)
	params += epb=7
	#   TODO
	params += hpet=force
	#   i915 Enable rc6 sleep state (?)
	params += i915.i915_enable_rc6=1
	#   TODO (Framebuffer?)
	params += i915.i915_enable_fbc=1
	#   Downclock the lvds screen (60hz -> 50hz)
	params += i915.lvds_downclock=1
        #   Quiet some of the excessively verbose kernel boot
        params += quiet
}

"Windows 7" {
        type win7
        params root=/dev/sda1
}

#"Funtoo Linux genkernel" {
#	kernel kernel[-v]
#	initrd initramfs[-v]
#	params += real_root=auto 
#} 

When you're done, update grub with

boot-update

Power Saving Local Scripts

Next we're going to set up a script that runs at default runlevel for the machine. This will echo several options to various dev files. Most distros would do this via /etc/rc.local or something of the like.

With Funtoo (and Gentoo) this is accomplished via

/etc/local.d

Consult the README (in directory) for more information.

$ cat /etc/local.d/power-saving.start
# /bin/bash
#
echo 1 > /sys/modules/snd_hda_intel/parameters/power_save
for i in /sys/bus/usb/devices/*/power/autosuspend; do
    echo 1 > $i
done
for i in /sys/class/scsi_host/host*/link_power_management_policy; do
    echo min_power > $i
done

If you copy this wholesale remember to chmod -x the file!

rc.conf

rc.conf lets us change some options to do with open RC.

First, lets set rc_sys to it's default, this will suppress a warning message at boot.

rc_sys=""

Next, we can turn on rc_parallel to get a bit of speedup on boot.

rc_parallel="YES"

If you get errors or problems with services on boot, try turning this off.

Making it Usable

Next we'll be setting up a normal user and installing the venerable Xorg.

Mouse in framebuffer

Right now we should be looking at a framebuffer'd console.

/etc/init.d/gpm start

gpm is a daemon that allows us to use our mouse (trackpad/trackpoint) on console. Give it a try! If you want to keep it on across boots, add it to your init.

rc-update add gpm default

Making a New User =

Lets use superadduser to make the task ever so much easier (Though, it is already easy)

emerge superadduser
superadduser

Walk through the prompts and set up your user how you choose.

Sudo Make Me a Sandwich

Next lets merge in sudo, and set up our new user to be able to use sudo.

emerge sudo

Now edit the config with

visudo

You'll probably want to uncomment out one of the two options:

## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

Now just add your user to the 'wheel' group.

gpasswd -a foouser wheel
exit

Now re-login as your user, and you should be good to go!

Tmux

Before we emerge xorg, lets get tmux working so we can easily scroll through output and look at USE flags etc.

emerge tmux

The default config will suffice for now. You may find it beneficial to learn to use tmux properly sometime, but for now we'll hold hands.

tmux

Now we can scroll through output with CTRL+B [ and the up and down arrows.

Xorg

Xorg is a large topic in and on itself. We'll focus on getting a working xorg and a simple window manager.

# (in tmux)
sudo emerge xorg-server

Once again use CTRL+B [ to start scrolling (escape to exit) and look through your use flags, adding anything you might want.

A note on Gnome

Want to get rid of that awful lock screen on wake from suspend?

gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true'