Skip to Content »

online discount medstore
advair diskus for sale
buy advair diskus without prescription
allegra for sale
buy allegra without prescription
aristocort for sale
buy aristocort without prescription
astelin for sale
buy astelin without prescription
atarax for sale
buy atarax without prescription
benadryl for sale
buy benadryl without prescription
buy clarinex without prescription
clarinex for sale
buy claritin without prescription
claritin for sale
buy flonase without prescription
flonase for sale
buy ventolin without prescription
ventolin for sale
amoxil for sale
buy amoxil without prescription
augmentin for sale
buy augmentin without prescription
bactrim for sale
buy bactrim without prescription
biaxin for sale
buy biaxin without prescription
buy cipro without prescription
cipro for sale
buy cleocin without prescription
cleocin for sale
buy dexone without prescription
dexone for sale
buy flagyl without prescription
flagyl for sale
buy levaquin without prescription
levaquin for sale
buy omnicef without prescription
omnicef for sale
amaryl for sale
buy amaryl without prescription
buy cozaar without prescription
cozaar for sale
buy diabecon without prescription
diabecon for sale
buy glucophage without prescription
glucophage for sale
buy glucotrol without prescription
glucotrol for sale
buy glucovance without prescription
glucovance for sale
buy micronase without prescription
micronase for sale
buy prandin without prescription
prandin for sale
buy precose without prescription
precose for sale
buy cialis professional without prescription
cialis professional for sale
buy cialis soft without prescription
cialis soft for sale
buy cialis super active without prescription
cialis super active for sale
buy cialis without prescription
cialis for sale
buy levitra without prescription
levitra for sale
buy viagra professional without prescription
viagra professional for sale
buy viagra soft without prescription
viagra soft for sale
buy viagra super active without prescription
viagra super active for sale
buy viagra super force without prescription
viagra super force for sale
buy viagra without prescription
viagra for sale
buy celebrex without prescription
celebrex for sale
buy colcrys without prescription
colcrys for sale
buy feldene without prescription
feldene for sale
buy imitrex without prescription
imitrex for sale
buy inderal without prescription
inderal for sale
buy indocin without prescription
indocin for sale
buy naprosyn without prescription
naprosyn for sale
buy pletal without prescription
pletal for sale
buy robaxin without prescription
robaxin for sale
buy voltaren without prescription
voltaren for sale

Tech Life of Recht » archive for 'linux'

 OpenOCES and Linux

  • April 7th, 2008
  • 10:08 pm

In Denmark, we have the OCES digital certificates, which are used for communication with the government, both for email and web signon. Web signon often runs through the OpenOCES java applet – a good old Java applet running AWT. Ugly as hell, but it works on just about any JVM or semi-JVM (like Microsoft’s).
Anyways, those of you who use it under Linux/Unix might have wondered how to put something in the dropdown box so you don’t have to go through the evil AWT file chooser every time you have to select a certificate. The documentation doesn’t really say it, but the trick is to put the certificate files (.p12 or .pkcs) files in ~/.oces.
Next time OpenOCES is activated, the files should be in the dropdown box. Excellent.

 Effective Bash

  • February 12th, 2008
  • 12:22 am

More and more people are coming into contact with Bash, primarily through Mac OSX and Ubuntu. All very nice, but most people really don’t realize the full potential of the Bash shell, so here are some advices on how to use Bash effectively (note to more advanced users: yes, some of the features are due to other facilities such as readline, but that’s not so interesting here). There’s also a quite large topic on scripting which will not be discussed here. I recommend the Advanved Bash-Scripting Guide, and you should always be familiar with the manpage for Bash.


Place all persistent changes in ~/.bashrc, which will be loaded every time a new shell is started. There’s no need to restart the computer, just start a new shell (or type bash in an existing).


Use the up/down arrows to go through the recently executed commands. This is basic, these commands will make it even better:
export HISTCONTROL=ignoredups
export HISTSIZE=10000
export HISTFILESIZE=10000

shopt -s cmdhist

Setting these will result in two things: Repeated commands will only appear once in the history, and the number of commands in the history will be increased to 10000.

Better prompt

Especially when using ssh, it’s easy to lose track of which machine you’re on. Setting an appropriate prompt can help. My prompt looks something like this:
recht@challenger: /home/recht >
In other words, it contains my current username, hostname, and directory. Also, the prompt is configured to set the title of the terminal to the same:

export PS1=”${TITLEBAR}\[\033[40;37;1m\]\u@\H: \[\033[37;40;0m\]\w > ”


Often used commands can be alised to a simple command. For example, the editor nano has an extremely annoying feature where lines are automatically wrapped unless nano is started with -w. An alias can make sure this is always so:

alias nano=”nano -w”

Other useful aliases:
alias rm=”rm -i”
alias cp=”cp -i”
alias mv=”mv -i”
alias ls=”ls –color=auto”
alias du=”du -h”
alias more=”less”

Auto completion

Autocompletion means entering a part of a command or filename, and then hitting TAB. If the command can be uniquely identified, the rest of the command is completed automatically, otherwise the possible completions are shown, and more characters can be entered.
By default, Bash only completes filenames, but it can actually do a lot more. This can either be hand coded, or you can use the completions which come with Bash.
The completions file is normally located in /etc/bash_completion. Use it by entering
source /etc/bash_completion
After this, almost anything can be completed: ant tasks, make targets, ssh hosts, and much more.Take a look in /etc/bash_completion for the complete list.

One other practical thing to set is this in ~/.inputrc:
set show-all-if-ambiguous on
If no unique completion is available, the possible completions are shown automatically.


It’s possible to use the keyboard to navigate commands, history and just about anything else.
The available keyboard commands can be seen in the manpage for Bash, but here are some of the most important:

  • Ctrl-a: Go to beginning of line
  • Ctrl-e: Go to end of line
  • Alt/Meta-b: Go back one word
  • Alt/Meta-f: Go forward one word
  • Ctrl-r: Search history backwards. Press Ctrl-r and enter part of an earlier command to find it in the history. Press Ctrl-r to search again.
  • Ctrl-d: Delete character
  • Ctrl-d on an empty line: Exit the shell
  • Ctrl-s: Stop sending data to the terminal. Nothing will be changed before pressing Ctrl-q
  • Ctrl-q: Start sending data to the terminal


Just about the most annoying thing any computer can do to me is beep or make any kind of unexpected sound – which is just about any sound not coming out of an MP3 player. The shell beeping is among the worst. Trade it with a flash by putting this in ~/.inputrc:
set bell-style visible

Changing directories

The cd command is use to change the current directory. Simple, but there’s still room for improvement.

If you mistype a directory, something which actually happens pretty often when you use completion without a unique name and hit enter without choosing the correct dir, an error occurs. However, Bash can also be configured to take a best guess:
set -s cdspell

For example, if I have to directories doc and download and type “cd do”, Bash will select doc for me. Of course, the correct dir is not always selected, so this option might annoy some more than others.

Typing cd with any arguments will return you to your home directory. Typing “cd -” will return you to the previous directory – nice when executing commands in two different directories.

Pager (less)

The pager is used when displaying text files. In the good old times, this was more, but the GNU alternative is less. There’s usually no reason to do it, but just to be safe, do
export PAGER=less

The standard configuration of less can be improved, however. My configuration looks like this:
export LESS=’-i -e -M -X -F -R -P%t?f%f \
:stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-…’
This basically enables case insensitive search, quit when end of file is reached, quits at once if entire content fits on the screen, and gives a nice prompt with line numbers. Look in the manpage for less for more info.

Just a few keyboard commands for less: Hit / and enter a string to search. Press n or N to search again. Enter a number and press g to go the the corresponding line number. Press q to quit.

Job control

Commands can be executed in a shell by typing in the command name and arguments. If the last character on the line is a ‘&’, the command will be run in the background. However, when the shell is closed, all background processes are also closed, so don’t rely on ‘&’ to run your server processes.

When processes are running in the background, type ‘jobs’ to see the processes and their status. If you want any of them attached again, run ‘fg’, possibly with the job number.

An attached process can be backgrounded by pressing Ctrl-z. This will stop the process and release the terminal. If you want the program to continue running while you’re doing something else, type ‘bg’.

This concludes what I see as the essential features of Bash (and readline and a couple of other things). If you do use Bash on a daily basis, do yourself a favor and continue with the Bash manual to discover more keyboard shortcuts. It might also be interesting to check up on the features of your terminal. I personally use urxvt, which can run as a daemon to avoid unnecessary overhead, plus it has some other nice features such as resizing.

 Updated script

  • February 10th, 2008
  • 11:35 pm

I got a comment that my SmugMug uploader script had broken after the last upgrade. It turned out that my XML parsing with sed wasn’t exactly resistant to change, so the wrong field was printed from the returned XML.
I’ve changed the XML parsing to use awk instead, hopefully in a way that’s a little more resistant to changes in the format (although it’s not exactly perfect, but I don’t want to involve a real XML parser).
The new version is 1.1, and can be downloaded here.

 2008 wishes

  • December 29th, 2007
  • 3:02 pm

The coming of a new year usually attracts a number of predictions, some more accurate than others. I’m no good at predicting, so I’ll give my wishes for the new year instead:

  • Get my Macbook Pro to work with the DVI-VGA adapter (done)
  • I’d like to be convinced that the dynamic languages are really the way forward. I see that they can do smart stuff, but I sorely miss some kind of help using whatever APIs are developed, besides the source code, and I can’t get used to working without a proper editor. I can probably live without the editor, but having methods like def initialize (options = {}) just hurts my eyes. I haven’t used Ruby/Rails that much, but I’ve already dug around more source code than I care to in order to find out what the legal options were.
  • Release Java 7 with proper closures. This probably won’t happen, and even when it does, it will take a couple of years before it’s adopted.
  • Already, I know that I’m going to spend a good part of my time fiddling around with huge WSDLs and schemas. Could somebody find a way to stop the black hole that is Web Services?
  • As for Linux on the desktop, that will still not happen, even though it should, especially when you look at the new distributions such as Ubuntu. However, I’m pretty satisfied, now I just need xmonad to support dynamic twinview, so I can add a monitor without restarting X
  • And to Apple: please take corporate customers seriously and make a docking station for the Macbook (Pro). I’m getting tired of plugging and unplugging 5 different cables every time I have to move my laptop.
  • Less focus on creating big monolithic systems, more on distributing across autonomous nodes.
  • Finally, it would be great with a proper vi-mode for Eclipse – like vimperator for Firefox.

 DVI adapter with Macbook Pro and Linux

  • December 29th, 2007
  • 2:36 am

I recently discovered that using the DVI adapter with the Macbook Pro wasn’t as easy as I thought. The MBP comes with a DVI connector, which is great, and it works just fine when you plug a DVI monitor into it. However, when doing presentations, you almost always have to use a regular VGA connector. Even though the driver (nvidia) could see the screen, it refused to display anything.
Now I’ve finally worked out a solution, and luckily it’s not that complicated. The trick is that even though the monitor is recognized, it is still treated as a DVI monitor. In order to get the driver to treat it as a normal VGA monitor, add this to xorg.conf:
Section “Device”

Option “ConnectedMonitor” “DFP-0,DFP-1,CRT-0”
Option “MetaModes” “DFP-0: 1440×900, DFP-1: 1680×1050; DFP-0: 1440×900, CRT-0: 1280×1024”

Of course, the modes should be adjusted according to the setup. The MetaModes line should contain the valid combinations, separated by ;. In this case, I’ve specified that the internal display should always run at 1440×900, and then I either have a DVI monitor connected at 1680×1050 or a VGA monitor at 1280×1024. Of course, it’s also possible just to specify one monitor if you’re not using TwinView.

The trick now is that when running in X, xrandr can be used to switch between the monitors. When running xrandr, it should display something like this:
Screen 0: minimum 1280 x 900, current 1440 x 900, maximum 2720 x 1024
default connected 1440×900+0+0 (normal left inverted right) 0mm x 0mm
1440×900 50.0* 51.0 54.0
2720×1024 52.0 50.0
2464×900 53.0
1280×1024 55.0

The tricky part now is that the nvidia driver “hides” the monitor configuration in the refresh rate. For example, the 1280×1024 resolution has only one rate, which means that this resolution is unique to one monitor. Switching to this mode with ‘xrandr -s 1280×1024’ will enable the VGA monitor and disable the internal display.
However, the mode 2720×1024 has two refresh rates, 52 and 50. Unfortunately there’s no easy way of telling it, but the 52 rate is with the internal display and the VGA monitor on, while the 50 is with only the internal display on (and a larger desktop, something you probably don’t want to use). Switching on the VGA monitor then requires two arguments: xrandr -s 2720×1024 –rate 52.

This isn’t the easiest to work with, so I’ve created a small Perl script which can query the nvidia driver directly to find the available modes, and then call xrandr. Download the script here. To use it, the X11::Protocol Perl package must be installed, and of course xrandr and the nvidia driver. To use the script, simply call it without any arguments to get a list of the supported resolutions and monitors. Select a configuration by calling the script with -s where id is one of the numbers in the first column. That’s about as simple as it gets.

 xmonad 0.5

  • December 16th, 2007
  • 12:57 am

xmonad 0.5 is out, and I haven’t upgraded my installation in a while. It’s pretty nice that configuration is now done in /.xmonad/xmonad.hs, then there’s no need to recompile xmonad all the time. The configuration change did require a reorganisation of my old Config.hs, so I took a look at some of the samples to see what other people did.
I ended up with something which looks like this:


This is my xmonad.hs:
— XMonad Core
import XMonad
import XMonad.Layout
import XMonad.Operations
import qualified XMonad.StackSet as W

— GHC hierarchical libraries
import Data.Bits ((.|.))
import qualified Data.Map as M
import Graphics.X11
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras
import System.IO

— Contribs
import XMonad.Actions.CycleWS
import XMonad.Actions.SwapWorkspaces
import XMonad.Actions.Submap
import XMonad.Actions.WindowBringer
import XMonad.Actions.FloatKeys

import XMonad.Hooks.UrgencyHook
import XMonad.Layout.NoBorders
import XMonad.Layout.Tabbed
import XMonad.Layout.WindowNavigation
import XMonad.Layout.Grid
import XMonad.Layout.LayoutHints
import XMonad.Layout.Dishes
import XMonad.Util.EZConfig
import XMonad.Util.Run

import XMonad.Prompt.Shell
import XMonad.Prompt

import XMonad.Hooks.DynamicLog ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )

myfont = “\”-xos4-terminus-medium-r-normal–12-120-72-72-c-60-iso8859-1\””
fgcolor = “black”
bgcolor = “white”

statusBarCmd= “dzen2 -e ” -w 660 -h 15 -ta l -xs 1 -fg ” ++ fgcolor ++ ” -bg ” ++ bgcolor ++ ” -fn ” ++ myfont

— Get ready!
main = do din <- spawnPipe statusBarCmd xmonad $ withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] } $ defaultConfig { workspaces = workspaces' , modMask = modMask' , numlockMask = 0 , layoutHook = layoutHook' , terminal = "urxvtc || urxvt" , normalBorderColor = "#dddddd" , focusedBorderColor = "#3499dd" , defaultGaps = [(15,0,0,0)] , logHook = dynamicLogWithPP $ myPP din } `additionalKeys` keys' modMask' = mod4Mask workspaces' = map show [1] ++ ["web", "mail", "chat", "code"] ++ map show [6 .. 9 :: Int] layoutHook' = configurableNavigation noNavigateBorders $ layouts layouts = Mirror tiled ||| tiled ||| Grid ||| layoutHints Full ||| Dishes 2 (1/5) ||| noBorders (tabbed shrinkText defaultTConf { fontName = myfont }) where tiled = Tall nmaster delta ratio nmaster = 2 -- The default number of windows in the master pane ratio = 1/2 -- Default proportion of screen occupied by master pane delta = 3/100 -- Percent of screen to increment by when resizing panes noFollow CrossingEvent {} = return False noFollow _ = return True keys' = [ ((modMask' .|. shiftMask, xK_d ), spawn "date | dzen2 -p 2 -xs 1") -- %! Print current date , ((modMask', xK_p), shellPrompt defaultXPConfig) ] ++ -- modMask'-[1..0] %! Switch to workspace N -- modMask'-shift-[1..0] %! Move client to workspace N [((m .|. modMask', k), windows $ f i) | (i, k) <- zip workspaces' $ [xK_1 .. xK_9] ++ [xK_0] , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] ++ -- modMask'-{e,r} %! Switch to physical/Xinerama screens 1 or 2 -- modMask'-shift-{e,r} %! Move client to screen 1 or 2 [((m .|. modMask', key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_e, xK_w] [0..] , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] ++ [((modMask' .|. mod1Mask, k), windows $ swapWithCurrent i) | (i, k) <- zip workspaces' $ [xK_1 .. xK_9] ++ [xK_0]] -- float keys ++ [ ((modMask', xK_d ), withFocused (keysResizeWindow (-10,-10) (1,1))) , ((modMask', xK_s ), withFocused (keysResizeWindow (10,10) (1,1))) , ((modMask', xK_a ), withFocused (keysMoveWindowTo (512,384) (1, 0))) ] myPP h = defaultPP { ppCurrent = dzenColor "white" "#cd8b00" . pad , ppVisible = dzenColor "white" "#666666" . pad , ppHidden = dzenColor "black" "#cccccc" . pad , ppHiddenNoWindows = dzenColor "#999999" "#cccccc" . pad , ppWsSep = dzenColor "#bbbbbb" "#cccccc" "^r(1x18)" , ppSep = dzenColor "#bbbbbb" "#cccccc" "^r(1x18)" , ppLayout = dzenColor "black" "#cccccc" . (\ x -> case x of
“TilePrime Horizontal” ->
” ^i(/home/emertens/images/tile_horz.xpm) ”
“TilePrime Vertical” ->
” ^i(/home/emertens/images/tile_vert.xpm) ”
“Hinted Full” ->
” ^i(/home/emertens/images/fullscreen.xpm) ”
_ -> pad x
, ppTitle = (‘ ‘:) . escape
, ppOutput = hPutStrLn h
escape = concatMap (\x -> if x == ‘^’ then “^^” else [x])
pad = wrap ” ” ” ”

I use a simple shell script for starting xmonad:

ssh-add ~/.ssh/id_dsa /dev/null
Esetroot /usr/share/backgrounds/warty-final-ubuntu.png
unclutter -idle 2 &
urxvtd -f -o
irxevent -d

gnome-settings-daemon &
gnome-volume-manager &

export PATH=$PATH:`dirname $0`
`dirname $0`/status &


Finally, the dzen2 status bar is run using this script:



gcpubar -i 2 -fg ‘#444’ -w 30 -h 10 | dzen2 -e ” -x 1360 -fg $FG \
-bg $BG -fn $FONT -h 15 -xs 1 &

while :; do
MEM=`memstatus.awk /proc/meminfo`
DATE=`date +”%d-%m %k:%M”`

REM=`awk ‘/remaining capacity/ { print $3 }’ /proc/acpi/battery/BAT0/state`
LAST=`awk ‘/last full/ { print $4}’ /proc/acpi/battery/BAT0/info`
STATE=`awk ‘{print $2}’ /proc/acpi/ac_adapter/ADP1/state`
if [ “$STATE” = “on-line” ]; then
BAT=$(echo $REM $LAST | awk ‘{printf “Bat: %.1f%%, AC”, ($1/$2)*100’})
PRESENT=`awk ‘/present rate/ { print $3}’ /proc/acpi/battery/BAT0/state`
BAT=$(echo $REM $LAST $PRESENT | \
awk ‘{printf “Bat: %.1f%%, %d min”, ($1/$2)*100, ($1/$3)*60}’)

LOAD=`awk ‘{print $1 ” ” $2 ” ” $3}’ /proc/loadavg`

echo “$CPU $MEM | $DATE | $BAT | $LOAD”
sleep 5
done | dzen2 -e ” -x 660 -w 700 -fg $FG -bg $BG -fn $FONT -h 15 -xs 1

Two awk scripts are used – one for the memory usage and one for CPU frequencies. Why awk? No idea, it just seemed like a good choice at the time.

#!/usr/bin/awk -f

/MemTotal/ {t=$2};
/MemFree/ {f=$2};
/SwapTotal/ {st=$2};
/SwapFree/ {sf=$2};


printf(“Mem: ^ib(1)^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)” \

#!/usr/bin/awk -f

cmd = “ls /sys/devices/system/cpu”
while ((cmd | getline) > 0) {
if ($1 ~ /cpu/) {

printf “CPU: ”
for (i=0; i < CPUS; i++) { cfn="/sys/devices/system/cpu/cpu" i "/cpufreq/scaling_cur_freq" mfn="/sys/devices/system/cpu/cpu" i "/cpufreq/scaling_max_freq" getline cf < cfn getline mf < mfn cw=int(WIDTH*(mf-cf)/mf) printf("^ib(1)^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)^ib(0)^fg()", FG, cw, HEIGHT, BG, WIDTH-cw, HEIGHT) close(cfn) close(mfn) if (i < CPUS - 1) { printf("^ib(0)^fg()^r(5x0)^ib(1)") } } printf("\n"); } [/code]

 Remote control with MacBook Pro and Ubuntu

  • October 28th, 2007
  • 5:44 pm

I managed to get the remote control to work with my MacBook Pro and Ubuntu. It should work out of the box according to almost everybody when you google for it, but it just didn’t. I know, I said ealier that I didn’t know what to use it for, but that doesn’t really matter. What matters is that I had a piece of hardware which didn’t work, and that’s just not good enough.
After digging around a little in lsusb and the module source code, I found out that on the most recent MacBooks, the IR receiver has been assigned a new device id. The original receivers had id 0x8240 while mine has 0x8242. It doesn’t look like anything else has changed, and after recompiling the module with the correct device it, it suddenly worked like it should.

Compiling the module isn’t exactly for the faint of heart, so I won’t describe the details here – let me know if you want it, and I’ll post it. However, it does include “apt-get source linux-ubuntu-modules-2.6.22-14-generic”.

Also, remember that the appleir module must be loaded before usbhid. To do this on a running system do
“rmmod appleir usbhid; modprobe appleir; modprobe udbhid”
Remember to do it on one line, or you will lose keyboard input after running rmmod.

Other than this, follow this guide to configure the remote control. So far, my .lircrc contains the following, supporting slide change in OOImpress and Amarok:

prog = irxevent
button = KEY_MENU
button = KEY_PP
config = Key space amarokapp
flags = quit
prog = irxevent
button = KEY_MENU
button = KEY_N
config = Key ctrl-alt-b amarokapp
flags = quit

prog = irxevent
button = KEY_MENU
button = KEY_MENU
config = Key Escape CurrentWindow

prog = irxevent
button = KEY_P
config = Key Page_Up CurrentWindow
prog = irxevent
button = KEY_N
config = Key Page_Down CurrentWindow

Btw, I’ve filed a bug with Ubuntu, so hopefully the module will be fixed at some point.

 Suspend success

  • October 27th, 2007
  • 12:37 am

as I wrote about yesterday, I had some problems getting software suspend to work with Ubuntu and my MacBook Pro. Well, it looks like the problem has been solved. As reported here, it looks like there’s a bug in the kernel, so downgrading a little should fix it. However, in my case I also had to disable gnome-power-manager – not really an issue. After changing these two things, I’ve been able to suspend and resume without problems – at least for now.

 My xmonad start script

  • October 25th, 2007
  • 10:54 pm

After reinstalling xmonad on my laptop using Ubuntu as the base distribution, I’ve finally got a setup I like, so I thought I’d share it. So, here is my script which starts xmonad:

ssh-add ~/.ssh/id_dsa /dev/null

Esetroot /usr/share/backgrounds/warty-final-ubuntu.png
unclutter -idle 2 &

urxvtd -f -o

gnome-settings-daemon &
gnome-volume-manager &


export PATH=$PATH:`dirname $0`

# create a pipe for xmonad to talk to
rm -f $PIPE
mkfifo -m 600 $PIPE
[ -p $PIPE ] || exit

# and a workspace status bar, reading’s xmonad’s stdout
dzen2 -e ” -w 680 -ta l -fg $FG -bg $BG -fn $FONT -h 15 < $PIPE & `dirname $0`/status & xmonad > $PIPE &
wait $!

pkill -HUP dzen2


This script is launched from ~/.xsession. It uses dzen and some of the dzen gadgets (which must be compiled separately from dzen/gadgets). It also starts some of the Gnome daemons which normally run under Ubuntu. This means that power management and sound volume goes through Gnome, and devices are mounted automatically when they are added to the system.

Two dzens are launched: One for displaying workspaces and one for general status. The general status script looks like this:



while :; do
MEM=`awk ‘/MemTotal/ {t=$2}; /MemFree/ {f=$2}; END {print t-f ” ” t}’ \
/proc/meminfo | dbar -s ‘:’ -l ‘Mem:’ -w 10`
CF0=$(echo `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` \
`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq` | dbar -w 7 -l ‘CPU0:’)
CF1=$(echo `cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq` \
`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq` | dbar -w 7 -l ‘CPU1:’)
DATE=`date +”%d-%m %k:%M”`

REM=`grep ‘remaining capacity’ /proc/acpi/battery/BAT0/state | awk ‘{print $3}’`
LAST=`grep ‘last full’ /proc/acpi/battery/BAT0/info |awk ‘{print $4}’`
STATE=`awk ‘{print $2}’ /proc/acpi/ac_adapter/ADP1/state`
if [ “$STATE” = “on-line” ]; then
BAT=$(echo $REM $LAST | awk ‘{printf “Bat: %.1f%%, AC”, ($1/$2)*100’})
PRESENT=`grep ‘present rate’ /proc/acpi/battery/BAT0/state | awk ‘{print $3}’`
BAT=$(echo $REM $LAST $PRESENT | awk ‘{printf “Bat: %.1f%%, %d min”, ($1/$2)*100, ($1/$3)*60}’)

LOAD=`awk ‘{print $1 ” ” $2 ” ” $3}’ /proc/loadavg`

echo “$CF0 $CF1 $MEM | $DATE | $BAT | $LOAD”
sleep 5
done | dzen2 -e ” -x 440 -w 1000 -fg $FG -bg $BG -fn $FONT -h 15


The script is made for a MacBook Pro with a two core processor and acpi. It displays the CPU frequencies in a dbar, memory usage, battery status, and load. I would like to display network status too, but I can’t figure out how to dig around in dbus efficiently, so that’s still missing.

 MacBook Pro

  • October 24th, 2007
  • 11:04 pm

Last week, we had some of the local drugheads come into the office at night, and they ran off with my laptop, and 6 other laptops. I had a trusty Lenovo Thinkpad z61m with Ubuntu (and xmonad, of course), which is now gone, together with whatever I had on it. Naturally, I didn’t have backup of everything, but at least all of my code was checked into Subversion, so the most critical I’m missing now are some course material.
Luckily, it didn’t take long before we got permission to go out and buy some new laptops (this is one of the great things when you’re working for a small company: no company procedures which have to be followed). We were told that we should probably go for a IBM, HP or Apple laptop. Now, I don’t know about you, but when I buy new hardware, I can’t just decide. It takes a couple of days (or even weeks), so deciding what to buy and live with for the next couple of years in half an hour certainly wasn’t easy. In the end, I got a MacBook Pro with a 15″ display – but only after confirming that it could run Linux, in case OS X got on my nerves too much.
Having lived with xmonad for a couple of months, it didn’t take long before I decided that OS X might be pretty nice, but there’s just too much focus on the looks, so I installed rEFIt, downloaded the new Ubuntu 7.10 and installed it.

I had anticipated some problems installing, as some of the experience reports on the net indicated that some things might go wrong, but that didn’t really happen. Everything just installed ™ – almost: The wireless driver had to be compiled from Subversion. Other than that, everything works: X, accellerated graphics, Xinerama/TwinView, sound, webcam, temp. sensors, keyboard lights, and touchpad with different zones. Only two things aren’t working: The remote control and suspend to ram.
I can live without the remote control (actually, I can’t really imagine what I should use it for if it worked), but the missing software suspend is not exactly optimal. It doesn’t help that it’s not consistent: Sometimes it can actually suspend and resume correctly. Using ‘pm-suspend –quirk-post-vbe’ seems to increase the number of times it works.
At other times, it doesn’t suspend. Sometimes, it just blanks the screen, and nothing else happend. It can also switch to console with a blinking cursor, and then nothing else happend. Sometimes bliking the cursor is so hard it has to turn on the fans. No matter what, a cold boot is the only way forward.
If it manages to suspend, resume often fails. When this happens, the disk turns on, but the screen doesn’t, and there’s no response to any keypresses. Again, cold boot is the way forward.
I haven’t managed to identify why software suspend doesn’t work. The only hint I have is that if the network cable is unplugged when I suspend, it seems to suspend successfully more often than else. Acpid should unload the network drivers before suspend, so I can’t see why this has anything to do with it. I’m hoping a kernel upgrade will fix it at some point.