An example awesomerc

logo

It’s been hard to find example awesomerc files to show how to use the progressbar and graph widgets in the awesome window manager. That’s understandable given the moving target. But, here’s the awesomerc file I’m using and the status.sh program that runs from my .xinitrc script. It currently works with commit b457c, based on the v2.1 tag.

widgets

Inside my .awesomerc

First of all, I have a few general additions to the default configuration:

general
{
    font = "terminus-9"
}
colors
{
    normal_border = "#2e3436"
    normal_bg = "#222222"
    normal_fg = "#aaaaaa"
    focus_border = "#336699"
    focus_bg = "#2e3436"
    focus_fg = "#c28457"
}

Here are the widget declarations I added:

    textbox tb1 { fg = "#336633" text = " CPU: " align = "right"}
    graph g_cpu
    {
        scale = false
        max = 100
        padding_left = 0
        width = 40
        height = "0.8"
        fg = "#551155"
        bg = "#000000"
        bordercolor = "#666699"
    }
    textbox tb2 { fg = "#336633" text = " Mem: " }
    progressbar pb_mem
    {
        bar { fg = "#551155" bg = "#000000" bordercolor = "#666699"  }
        width = "40"
        height = "0.4"
        gap = -1
        padding_left = 0
    }
    textbox tb3 { fg = "#336633" text = " | " }
    textbox tb_date { fg = "#c28457" text = "" }

You can download my latest .awesomerc here. Diff it with the awesomerc in the awesome distribution to see all my changes and upgrade to the latest version of awesome — it changes fast!

Lastly, my complete bin/status.sh

#/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 0 widget_tell tb_mpc "$mpc_text" | awesome-client
echo 0 widget_tell g_cpu "$pcpu" | awesome-client
echo 0 widget_tell tb_mem "$pmem%" | awesome-client
echo 0 widget_tell pb_mem "$pmem" | awesome-client
echo 0 widget_tell tb_date "$date" | awesome-client

sleep 3
done

Related Posts

Tags:
Posted in linux on January 25th, 2008 |

3 Responses

  1. Stephen Lange Says:

    Would it be possible for you to post your entire .awesomerc file? I am having difficulties adding your code. Thanks!

  2. Mychael Says:

    Stephen,
    Excellent suggestion!

    I’ve added a link in the article to my latest .awesomerc: here. It is currently working for the latest commit (170ed).

    Any ideas for improvement, or better color ideas for the widgets? Please let me know!
    Mychael

  3. Ricardo Says:

    Thanks for the article!

    Hope that you continue sharing your experiences with awseome.

    :)

Leave a Comment

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