[ last updated 12/08/2007 ]
If you want so use your machine at 100%, then you probably need a light and fast environment, having all your resources dedicated to your music software. So it is time now to install a real fast Window Manager, called dwm. Give it a try, it is really fantastic! Oh, I forgot one thing : this is Linux only ;) . Here I will show an install on a fedora 7 system. However this will work on any Linux distribution.
Please refer to the dwm website for accurate instructions : http://dwm.suckless.org/
Prerequisite
Of course, you will need X11 development libraries. Optionnaly, you can install mercurial, in order to download the code easily.
sudo yum install libX11-devel mercurial subversion
Download and compile the code
The code consists of dwm , the core window manager , and
dmenu an utility de generate menus, useful when you want to execute a command directly with name-completion. I also use
dzen to write some notifications at top of the screen.
cd /usr/local/src
hg clone http://www.suckless.org/hg.rc/dwm
hg clone http://www.suckless.org/hg.rc/dmenu
svn checkout http://dzen.googlecode.com/svn/trunk/ dzen
cd /usr/local/src/dmenu
sudo make clean install
cd /usr/local/src/dwm
sudo make clean install
cd /usr/local/src/dzen
sudo make clean install
Start dwm
There are many ways to start dwm, depending of you logon manager. The file used is one of .xinitrc , .Xclients , .Xclients-default ... I currently use xdm because it is simple and fast. Here is my
.xinitrc :
#!/bin/bash
#
. /etc/X11/xinit/xinitrc-common
xscreensaver&
(sleep 2;~/bin/monitor.sh) &
exec /usr/local/bin/dwm
monitor.sh is a script I wrote. It gives various information from my computer (date, time, cpu, memory, battery...).
You can write your own script of course. Here is the code :
monitor.sh
#!/bin/bash
# Lobzang - 12/08/2007
#
cpu() {
[ -f /tmp/FILE1 ] && mv /tmp/FILE1 /tmp/FILE2 2>/dev/null
cat /proc/[1-9]*/stat 2>/dev/null | awk ' { printf $1" "$2" "$14" "$15"\n" } ' > /tmp/FILE1
[ $duration -eq 0 ] && return
cat /tmp/FILE[1-2] | sort -n -k 1 | awk -v duration=$duration ' {
oldps=ps;oldcp=cp;ps=$1;cp=$3+$4
if ( oldps==ps ) { cpu=int((cp-oldcp)/duration) }
else {
if (cpu>2*duration) {
a=cpu/2;if (a>15) a=15
printf ("^fg(#%x%x%x)cpu %s %s \n",a,4,16-a,cpu,command) }
if ( (cpu==-1) && ( oldcp>2*duration) ) {
c=int(oldcp/duration);a=c/2;if (a>15) a=15
printf ("^fg(#%x%x%x)cpu %s %s \n",a,4,16-a,c,command) }
cpu=-1;command=$2; }
} ' | sort -n | tail -1 | awk ' { printf $0 } '
}
heure() {
date "+%Y/%m/%d %H:%M"
}
up() {
uptime | cut -d, -f 3 | awk -F: ' $2>0.1 { a=$2*16;if(a>15) a=15;printf ("^fg(#%x3%x)load:%s ",a,16-a,$2+0) } '
}
proc() {
awk -F: ' $1~"cpu MHz" && $2>600 { a=($2-600)/70;printf ("^fg(#%x3%x)%iMHz ",a+1,15-a,$2) } ' /proc/cpuinfo
}
mem() {
awk ' /MemTotal/ {t=$2} /MemFree/ {f=$2} /Buffers/ {b=$2} /Cached/ { a=int((f+b)/t*700);if (a>15) exit
printf(color"^fg(#%x3%x)%dMb ",16-a,a,(t-f-b-$2)/1024) } ' /proc/meminfo
}
proctemp() {
awk ' { a=($2-40)*2;if (a>15) a=15;if (a<0) a=0;printf ("^fg(#%x3%x)%s°C ^fg(#068)",a,15-a/2,$2) } ' /proc/acpi/thermal_zone/THM/temperature
}
battery() {
[ $cycle -eq 0 ] && cat /proc/acpi/battery/BAT0/info /proc/acpi/battery/BAT0/state > /tmp/battery
awk ' $0~/remaining capacity:/ { r=$3 } $0~/last full capacity:/ { l=$4 } $0~/charging state:/ { status=$3 }
END { if ( status!="charged" ) {
taux=r/l*100;a=taux/7;if (a>16) a=16
if (status=="charging") a=15
printf ("^fg(#%x%x%x)%s:%00.01f%% ",16-a,a/4+3,a/2+4,status,taux) } } ' /tmp/battery
}
weather() {
wget http://weather.noaa.gov/pub/data/observations/metar/decoded/LFLS.TXT -O - | awk ' /Temperature:/ { printf $4"°"$5 } /Pressure/ { printf $6" "$7} '
}
icq() {
icqinfo=$(xwininfo -root -children -tree | grep "event from" )
[ $? -gt 0 ] && printf "\n" && return
icqaccount=$(echo $icqinfo| awk ' {printf substr($5,2,1)substr($6,1,length($6)-2) } ')
message=$(tail -1 ~/.centericq/$icqaccount/history)
printf "^fg(#f8f)^bg(#303)$icqaccount : $message ^bg(#011) "
}
####################
LANG=en_US.ISO8859-1
DISPLAY=:0.0
duration=5
font="-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-1"
rm /tmp/FILE*
geometry=$(xwininfo -root -stats | grep geometry | awk ' { printf $2 } ' | cut -d+ -f 1)
x=$(echo $geometry|cut -dx -f 1 );let x=x-600
while true
do
cycle=$(echo $((RANDOM%$duration)))
p=`proc`;NET2=$NET1;NET1=$(netstat -i | grep eth )
NET=$(printf "$NET1 $NET2" | awk -v duration=$duration ' { net=int(($4-$16)*$2/1024/duration) ; if ( (net>16) && ($16 > 0)) { a=net/10;if (a>15) a=15;printf ("^fg(#%x%x%x)net:%sK ",a,3,16-a,net)} } ')
echo $(icq;mem;cpu;battery;up)$NET$p$(proctemp;heure);sleep $duration
done | /usr/local/bin/dzen2 -u -ta r -x $x -w 600 -fn $font -bg "#011"
Setup and configuration
All setup is done with the file
config.h in /usr/local/src/dwm . You can change the keyboard
shortcuts, and add some new ones, change the default colors.
Here is what I updated :
- I have an azerty keyboard , so ALT+[1/2/3...] didn't work. I changed it to ALT+[a/z/e...]. You could also use ALT+[F1/F2/F3...] . If you want however, you can use ALT+1/2/3/4 using the following configuration : ( find more information with :
less /lib/kbd/keymaps/i386/azerty/fr.map.gz )
You can also grab keaboard keycodes with
xev command...
{ MODKEY, XK_ampersand, view, "0" }, \
{ MODKEY, XK_eacute, view, "1" }, \
{ MODKEY, XK_quotedbl, view, "2" }, \
{ MODKEY, XK_apostrophe, view, "3" }, \
- I replaced xterm by
urxvt which is really fast and powerfull, with utf and transparency support. If you want to install it, the package name is
rxvt-unicode .
- I added a shortcut to
lock my screen :
{ MODKEY, XK_F12, spawn, { .cmd = "exec xscreensaver-command -lock" } }, \
- I added a new shortcut to ssh to any machine, using dmenu and
ssh completion. This can be really usefull! For this I created a very small script that I called
dssh.sh
{ MODKEY|ShiftMask, XK_p, spawn, { .cmd = "exec dssh.sh" } }, \
- you can tell dwm on which workspace you want to start a specific program. you can also choose the default mode (Tiled/Float). I start centericq with : "urxvt -name aim -e centericq" . That way the name aim is used to control the desired worspace.
{ "Firefox.*", "4", False }, \
{ "Evolution.*", "3", True }, \
{ "aim", "2", False }, \
- finally I changed the font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-1"
Remember to
compile dwm again once you have finished your configuration.
Basic key bindings
Now everything should be easy :
- you can control all your worspaces with your left hand
- open a new
terminal with
ALT+SHIFT+RETURN
-
cycle through your windows
with ALT+TAB
- change the window
focus with
ALT+RETURN
- launch a new
program with
ALT+p
- change from
Tiled mode to
Float mode with
ALT+SPACE, and back again