Set Monitor Brightness with xbacklight script

Updated September 09, 2008 @ 16:37 PDT

I’m sure that everyone’s ubuntu-based gnome applet for brightness works, but my laptop’s x3100 doesn’t work with it. It does work with xbacklight. Here is simple script for attaching to icon for your gnome panel:

#!/bin/bash

# monitor_switcher

app=`which xbacklight`
current=`$app -get`
ans=$(zenity --scale --text "Set LCD brightness 0-100" --value "${current%%.*}");
$app -set $ans

Just name this something like monitor_switcher and put into path on your system, then you can use wherever to get a basic slider for setting your brightness. Yes, please make it shorter, prettier or just fix the brightness gnome applet which I’m too lazy to do :)

Fix Your MTRR on Gentoo with Thinkpad x61 Intel x3100

Updated August 06, 2008 @ 10:23 PDT

I’ve noticed for ages that my thinkpad x61 with 4 gigs of ram has been sluggish on the desktop with redraws. Now that I have a bit more time, I looked into this, oh, and because I’ve been shamed into getting all the funky compiz-fusion graphics looking hot on my desktop by Freddie B and Mr. Adams.

After some gentoo forum spelunking into the issue across distros, I found out that at least with Intel 965 (x3100) and kernel 2.6.25-26, there are some major issues with mtrr not being set properly.

I took the plunge at trying to understand the issue and wrote a basic script to fix-up my mtrr settings from the commandline:

#!/bin/bash
#
# fixmtrr
#
# fixes /proc/mtrr
# based upon termites script from gentoo forums

# disable pre-existing ones and order does matter!
echo "disable=0" >| /proc/mtrr
echo "disable=1" >| /proc/mtrr
echo "disable=3" >| /proc/mtrr
echo "disable=4" >| /proc/mtrr
echo "disable=5" >| /proc/mtrr
echo "disable=2" >| /proc/mtrr

# Now create the right ones...

# These are powers of two, they get progressively smaller
# so we can get right up to the system device page below.
echo "base=0x00000000 size=0x80000000 type=write-back" >| /proc/mtrr
echo "base=0x80000000 size=0x40000000 type=write-back" >| /proc/mtrr
echo "base=0xC0000000 size=0x10000000 type=write-back" >| /proc/mtrr

# Video Card:
# 0x10000000 was the value for size trying for
echo "base=0xE0000000 size=0x10000000 type=write-combining" >| /proc/mtrr

# High memory area
echo "base=0x100000000 size=0x40000000 type=write-back" >| /proc/mtrr

This helped to set my mtrr up right so that X can find the dynamic shared memory to do all the fun compiz effects and more. If there is a better fix for the above, I’d love to hear about it! More than just bling bling, my overall computer is much much better. I can’t believe I put up with this!

Then, I started running powertop to test out my system, and noticed that there are many features that can be set after a computer is setup, so I created an init script to set all this at boot:

!/sbin/runscript
#
# This starts the thinkpad post-boot settings
#

TITLE="Thinkpad Specific Options"
LINKPOWER=/sys/class/scsi_host/host0/link_power_management_policy
FIXMTRR=/usr/local/bin/fixmtrr
WRITEBACK=/proc/sys/vm/dirty_writeback_centisecs

checkconfig() {
    if [ ! -e $LINKPOWER ] &&
       [ ! -e $FIXMTRR ] &&
       [ ! -e $WRITEBACK ] ; then
        eerror "You cannot set $TITLE. Check settings."
        return 1
    fi
}

start()
{
    checkconfig || return 1

    ebegin "Starting $TITLE"
    $FIXMTRR
    echo min_power > $LINKPOWER
    echo 1500 > $WRITEBACK
}

stop()
{
    checkconfig || return 1

    ebegin "Stopping $TITLE"
    echo 500 > $WRITEBACK
}

Make sure to put the fixmtrr script in /usr/local/bin or change the path to fixmtrr in your script. Then, set thinkpad script to run at boot before xdm kicks in:

rc-update add thinkpad boot

These are pretty basic scripts, but I wanted to dump them out for other users of this system. Its beyond just Gentoo-based distros, and will take a while to get into main kernel especially for slow distros like Ubuntu, Fedora, etc ;)

I had to put that one in there for those who try to convert or chide me off Gentoo.

Dear Lazyweb, Need Simple Encrypted Backup Method to USB on Linux

Updated May 26, 2008 @ 01:10 PDT

Ok, the title pretty much says it all. Lu bought me a new 250 gb backup drive for locking down my backups while on the road (and I already have a halfway solution at home thanks to advice from readers). I’m curious what is the best option for syncing up my 80 gb thinkpad x61 to a partition on this drive, which can act as a daily backup, and be used in the event of something bad? I run gentoo on my computers currently, and want to just do more than just rsync to this drive in that I want the content encrypted.

Please help me lazyweb! Another option is to pay for a service like mozy.com or carbonite, but I want to stay in commandline realm and where I don’t need network access..