Wednesday, April 23, 2008

e17 profile backup script


Given that E17 uses binary config files, and these may get hosed without warning, it is useful to back them up after making changes.

The following shell script will do just that, via tar:

#!/bin/sh

[ -d ~/.e/backup ] || mkdir -p ~/.e/backup

tar -zcf ~/.e/backup/e17-config-$(date +%F-%T).tgz ~/.e/e


Also worth noting is an improved way of using the E17 profile switching for extending battery life: put a shell script for switching to the battery profile in /etc/acpi/battery.d, and one for switching to the A/C profile in /etc/acpi/ac.d . Note that this occasionally causes E17 to crash (and take X with it), so be conservative.

Current configuration:
  • Smoke theme, Darkness startup, Slick icons
  • 10 1x1 virtual desktops
  • XRENDER engine with Composite disabled
  • 3 profiles (AC, battery, and default)
  • Run command: uxterm -bg black -fg orange -fa 'xft:Courier New' -fs 11 -hold -e
  • Shelf (invisible, below windows, shrink:48, all desktops) on upper right-top (Contents: cpufreq, mixer, winselector, battery, deskshow, tclock, temperature, exalt)
  • Shelf (invisible, below windows, shrink:60, all desktops) on lower left-left (Contents: Pager)
  • Shelf (default, below everything, shrink:40, all desktops, auto-hide) on upper left-top (Contents: Start, IBar, Taskbar)
  • Shelf (invisible, above everything, shrink:40, all desktops, auto-hide) on lower right-bottom (C0ntents: IBox)
  • Shelf( default, above everything, shrink:48, desktop 0:0, auto-hide) on lower-right-right (Contents: News, Forecasts)

I should note that Forecasts doesn't seem to work at all. I also disabled the screen savers, lock, and power management as they are all a bit crashy.

The screenshot isn't much to look at.

Friday, April 18, 2008

Powertop && Latencytop

Now that most everything is working (sans the crappy TI SD reader) on a good solid kernel, it's time to break stuff by adding powertop and latencytop. Laptop users should play with powertop a bit to find out how to lower their power consumption; latencytop can be useful in debugging lagged or unresponsive applications.

sudo apt-get install powertop

http://www.latencytop.org/

The latencytop patch applies cleanly to 2.6.24.2, and requires CONFIG_SCHEDSTATS be set. Powertop requires CONFIG_TIMER_STATS and suggests many more adjustments while it is running ( though apparently the usbcore.autosuspend advice is deprecated).

On an unrelated topic, now that inttab is gone the settings for terminals (you know, respawn getty and all that) is in tty-specific files in /etc/event.d . Why? Who knows! Maybe they're trying to reduce the AT&Tness of their *nix.

Thursday, April 17, 2008

Hibernation

Spent the extra hour and got hibernation working last night; here are some basic notes on the experience.

The only truly working suspend-to-disk implementation is Suspend2 AKA Tux-On-Ice (TOI), available as a kernel path from http://www.tuxonice.net/downloads .

Download and path the kernel as follows:

cd /usr/src/linux-2.6.24-2
patch -p1 < /tmp/tuxonice-3.0-rc5-for-2.6.24.patch


Make config/menuconfig/xconfig and ensure the following options are set:

CONFIG_TOI_CORE=y

# Image Storage (you need at least one allocator)
CONFIG_TOI_FILE=y
CONFIG_TOI_SWAP=y
CONFIG_TOI_DEFAULT_PRE_HIBERNATE=""
CONFIG_TOI_DEFAULT_POST_HIBERNATE=""
CONFIG_TOI_CRYPTO=y
CONFIG_TOI_USERUI=y
CONFIG_TOI_USERUI_DEFAULT_PATH="/usr/lib/suspend2-userui/suspend2ui_fbsplash"
# CONFIG_TOI_KEEP_IMAGE is not set
CONFIG_TOI_REPLACE_SWSUSP=y
# CONFIG_TOI_CLUSTER is not set
CONFIG_TOI_CHECKSUM=y
CONFIG_TOI_DEFAULT_WAIT=25
CONFIG_TOI_DEFAULT_WAIT=25
# CONFIG_TOI_PAGEFLAGS_TEST is not set
CONFIG_TOI=y
...
CONFIG_CRYPTO_LZF=y


Rebuild/reinstall the kernel. If you use an initrd or initramfs, a new one must be made according to the instructions at:
http://wiki.tuxonice.net/DistroAndHardwareSetup/Ubuntu_Gutsy_Gibbon

Note that the initramfs files may exist both in /etc/initramfs-tools and /usr/share/initrafms-tools ; in this case, create the file suspend2_do_resume in /etc/initramfs-tools . I had to fill my /etc/initramfs-tools tree with files from the /usr/share/initramfs-tools tree; it now looks like this:

/etc/initramfs-tools/update-initramfs.conf
/etc/initramfs-tools/hook-functions
/etc/initramfs-tools/init
/etc/initramfs-tools/hooks/console_tools
/etc/initramfs-tools/hooks/console_setup
/etc/initramfs-tools/hooks/usplash
/etc/initramfs-tools/hooks/thermal
/etc/initramfs-tools/hooks/kernelextras
/etc/initramfs-tools/hooks/uswsusp
/etc/initramfs-tools/hooks/udev
/etc/initramfs-tools/initramfs.conf
/etc/initramfs-tools/scripts/init-premount/udev
/etc/initramfs-tools/scripts/local-premount/suspend2_do_resume
/etc/initramfs-tools/scripts/local-premount/uswsusp
/etc/initramfs-tools/scripts/nfs
/etc/initramfs-tools/scripts/functions
/etc/initramfs-tools/scripts/nfs-top/udev
/etc/initramfs-tools/scripts/local
/etc/initramfs-tools/scripts/init-top/console_setup
/etc/initramfs-tools/scripts/init-top/framebuffer
/etc/initramfs-tools/scripts/init-top/usplash
/etc/initramfs-tools/scripts/init-top/all_generic_ide
/etc/initramfs-tools/scripts/init-bottom/udev
/etc/initramfs-tools/conf.d/resume
/etc/initramfs-tools/modules

The initramfs is rebuilt with the command
update-initramfs -u -k `uname -r`

The following config settings work fine:

/etc/hibernate/suspend2.conf
UseSuspend2 yes
Reboot no
EnableEscape yes
DefaultConsoleLevel 1
Compressor lzf
Encryptor none
SuspendDevice swap:/dev/sda2
FullSpeedCPU yes


/etc/hibernate/common.conf :
Verbosity 1
LogFile /var/log/hibernate.log
LogVerbosity 4
LogTimestamp yes
HibernateVT 15
Distribution debian # (or fedora/gentoo/mandrake/redhat/slackware/suse)
XDisplay :0
SaveClock restore-only
ChangeGrubMenu yes
GrubMenuFile /boot/grub/menu.lst
AlternateGrubMenuFile /boot/grub/menu-suspended.lst
BackupGrubMenuFile /boot/grub/menu.lst.hibernate.bak
UnloadBlacklistedModules yes
LoadModules auto
SwitchToTextMode yes

Note that /boot/grub/menu.lst must be copied to menu-suspended.lst, which will be the boot menu displayed when the system is hibernating. Add the line "resume=swap:/dev/sda2" (or whatever your swap partition is) to the default kernel boot option, and add a kernel boot option with the No Resume (param is "noresume") option set for easy recovery in case of failure.

The command "hibernate -v3" should now susend the system to disk.

Apropos of nothing: Ubuntu has the default language set to require UTF-8 (e.g. en_US.UTF-8), which really screws up compiler output, man pages, and so forth (in particular, single and double quotes appear as f’s) in non-Unicode terminals (e.g. Aterm, Eterm). One could switch to a unicode terminal, e.g.
rxvt-unicode -bg black -fg orange -fade 25 -fn 'xft:Courier 10 Pitch-12'
...but setting the language to C in ~/.bashrc (export LANG=C) lets you keep using your favorite terminal.

Wednesday, April 16, 2008

toshiba_acpi, toshset, and transreflectivity

The new version of toshset (1.73, available at http://www.schwieters.org/toshset ) supports the r500 transreflective screen via the option

toshset -trmode

Usage is simple: to turn the backlight off and use the display in direct sunlight, type

toshset -trmode off

To turn the backlight back on, type

toshset -trmode on

Note that you can still use the display in direct sunlight without turning the backlight off (this works fantastically, btw). The trmode option simple saves you (much) power.

There are some caveats to getting this to work, however:

1. The toshiba kernel module must not be loaded, so remove it from /etc/modules .
2. The character device 181 must be associated with toshiba_acpi kernel module, not the toshiba kernel module. This change can be made in /etc/modprobe.d/aliases .
3. The patch toshiba_acpi-dev_toshiba_test5-linux_2.6.21.patch must be applied. This works fine with the 2.6.24 kernel :
cd /usr/src/linux-2.6.24-2
cd drivers/acpi
patch -p0 < /tmp/toshiba_acpi-dev_toshiba_test5-linux_2.6.21.patch
cd ../..
make modules
make modules_install

4. If the file /etc/modprobe.d/toshiba_acpi.modprobe exists, open it and comment out the line
options toshiba_acpi hotkeys_over_acpi=1

The fingerprint reader supposedly works with libfprint (no Ubuntu package, not bothering).
The SD card reader still cannot read cards (mmc0: error -110 whilst initialising SD card).
Hibernation (aka suspend-to-disk) still doesn't resume, probably because of Ubuntu's swap-device-UUID-changing problem.

One more fun fact: change the Xorg driver from 'i810' to 'intel' :
Driver "intel"
Helps keep X from hanging due to an illegal instruction. Isn't running Linux fun?