awesome, a tiling window manager

logo

Lately I’ve been using a tiling window manager, which presents a different paradigm for window management. Instead of having to manage your windows yourself, with a tiling window manager, you are given a default arrangement that maximizes your use of screen real estate. As you open and close windows, it places and resizes windows appropriately.

Other tiling window managers are wmii and dwm. I really enjoy the column-based interface of wmii. In wmii you have columns of windows, and you can maximize and cycle through windows per column. As needed, you can easily move windows from one column to the other, and create or delete windows at will. But wmii’s scripting language made it a bit too involved for me. I needed more control, which dwm promised to give me. In the end, I found myself adding patches that had already been addressed in a dwm fork, awesome. With a few changes of my own, it has been my preferred window manager as of late. There is quite a shift getting used to a tiling window manager, but I think it is worth it.

awesome is written in C, and has a simple codebase. I’ve made some changes to it so that each screen has its own layout. If I change the width of a column or the number of windows in the main column on a screen, I don’t necessarily want that layout on every other screen. On one window, I may have my mail open, my calendar, and pidgin. On another screen I may have a webpage I’m reading, a source file I’m editing, and some API documentation that I’m browsing. For these two screens I want completely different layouts, and I want them to remain how I left them as I move around between screens.

In general, tiling window managers allow you a lot of power with only the keyboard. Between awesome and Vimperator, I can use only the keyboard for large stretches of the day when I don’t want the distraction of reaching for a mouse. During those times when I want to idly browse the internet, :set guioptions=T allows me to use the mouse and enjoy the debauchery of idle laziness.


Here is a script I run from my .xinitrc before launching awesome:

~/bin/status.sh | awesome-client `echo $DISPLAY | cut -f1 -d.` &

This script, ~/bin/status.sh updates the statusbar in awesome:

#/bin/bash

while true;
do
date=`date +"%Y.%m.%d %l:%M" | sed 's/  / /g'`


### CPU
CPUSTAT="$HOME/.cpustat"
old_cpu_vals=(`head -1 "$CPUSTAT"`)
cpu_old_user=${old_cpu_vals[0]}
cpu_old_nice=${old_cpu_vals[1]}
cpu_old_system=${old_cpu_vals[2]}
cpu_old_idle=${old_cpu_vals[3]}
cpu_old_total=`echo "$cpu_old_user + $cpu_old_nice + $cpu_old_system + $cpu_old_idle" | bc`

cpu_vals_text=`cat /proc/stat  | head -1 | sed -e 's/^cpu[^0-9]*//g' -e 's/\([^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+\).*/\1/g'`
cpu_vals=($cpu_vals_text)
cpu_user=${cpu_vals[0]}
cpu_nice=${cpu_vals[1]}
cpu_system=${cpu_vals[2]}
cpu_idle=${cpu_vals[3]}
cpu_total=`echo "$cpu_user + $cpu_nice + $cpu_system + $cpu_idle" | bc`
pcpu=`echo "(100 * ($cpu_system - $cpu_old_system + $cpu_user - $cpu_old_user)) / ($cpu_total - $cpu_old_total)" | bc`
echo $cpu_vals_text > "$CPUSTAT"


### MEMORY
mem_vals=`free -m | grep '^Mem:' | sed 's/Mem://g'`
mtot=`echo $mem_vals | sed 's/ .*//g'`
muse=`echo $(echo $mem_vals | cut -f2,5,6 -d" " | sed 's/ / - /g') | bc`
pmem=`echo "100 * $muse / $mtot" | bc`


### MPD
mpc_lines=`mpc | wc -l`
vol=`mpc | grep 'volume:' | sed -e 's/volume: //' -e 's/ .*//g'`
mpc_text="stopped @ $vol"
if [[ $mpc_lines -gt 1 ]]; then
    song=`mpc | head -1`
    status=`mpc | grep '^\[' | sed -e 's/ .*//' -e 's/[^a-zA-Z]//g'`
    mpc_text="$song @ $vol"
fi


### MAIL
if [ -f "$MAIL" ]; then
    mail_tot=`cat "$MAIL" | grep -c '^From '`
    mail_old=`cat "$MAIL" | grep '^Status: ' | grep -c 'O'`
    mail_new=`echo "$mail_tot-$mail_old" | bc`
    if [[ $mail_new -eq 0 ]]; then
        mail_new="-"
    fi
    if [[ $mail_tot -eq 0 ]]; then
        mail_tot="-"
    fi
    mail_text="$mail_new/$mail_tot"
else
    mail_text="-/-"
fi


### UPTIME
uptime=`uptime | sed 's/.* \([0-9]\+ days\).*/\1/' | tr -d '[ a-zA-z]'`


### SWAP
swap_vals=`free | grep 'Swap: ' | sed 's/.*: *\([0-9]\+\) \+\([0-9]*\).*/\1 \2/'`
swap_tot=`echo $swap_vals | cut -f1 -d" "`
swap_use=`echo $swap_vals | cut -f2 -d" "`
pswap=`echo "100*$swap_use / $swap_tot" | bc`


#echo $pswap
#echo $uptime
#echo $mail_tot
#echo $mail_new
#echo $song
#echo $status
#echo $vol
#echo $pmem
#echo $date
#echo $pcpu

echo "0 setstatustext $mpc_text | $pcpu% | $pmem% | $mail_text | $date"
sleep 3
done

Related Posts

Tags:
Posted in linux on November 9th, 2007 |

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.