«前の日記(2008-03-31(月)) 最新 次の日記(2008-04-05(土))» 編集
RSS feed

からっぽの日記


2008-04-04(金) [長年日記]

awesome 2.1-1 -> 2.2~rc4-1

Debian testing の awesome がバージョンアップしたら、以前設定したファイルにエラーが出るようになったので修正。適当に man 読みながら直したけど、一度整理しないとダメかねぇ。

~/.awesomerc の「statusbar」の箇所

        textbox tb1 { fg = "#3CB371" text = " CPU: " align = "right" }
        graph g_cpu
        {
            data cpu
            {
                scale = false
                fg = "#CE00CE"
                max = 100
            }
            width = 40
            height = "0.8"
            align = "right"
            bg = "#000000"
            bordercolor = "#666699"
        }
        textbox tb2 { fg = "#3CB371" text = " Mem: " }
        progressbar pb_mem
        {
            data mem
            {
                fg = "#CE00CE"
                bg = "#000000"
                bordercolor = "#666699"
            }
            width = "40"
            height = "0.4"
            align = "right"
            gap = -1
        }
        textbox tb_space { fg = "#336633" text = " " }
        textbox tb_mem { fg = "#3CB371" text = "" }
        textbox tb3 { fg = "#3CB371" text = " MAIL: " }
        textbox tb_mail { fg = "#3CB371" text = "" }
        textbox tb4 { fg = "#3CB371" text = " BAT: " }
        textbox tb_battery { fg = "#3CB371" text = "" }
        textbox tb5 { fg = "#336633" text = " | " }
        textbox tb_date { fg = "#DAA520" text = "" }

「data」というセクション?がなかったのがダメだった模様。

statusbar に値を渡しているシェルスクリプトも修正。

#/bin/bash

CPUSTAT="/tmp/.cpustat"
mail=`ruby $HOME/bin/mail_checker.rb`

if [ -f "$CPUSTAT" ]; then
    touch $CPUSTAT
fi

while true;
do
date=`LC_ALL=C date +"%Y.%m.%d(%a) %H:%M" | sed 's/  / /g'`


### CPU
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`

### BATTERY
full_battery=`cat /proc/acpi/battery/BATA/info | grep ^last | sed 's/last full capacity:      \([0-9]*\) mWh/\1/g'`
if [ -n "$full_battery" ]; then
    remain_battery=`cat /proc/acpi/battery/BATA/state | grep ^remaining | sed 's/remaining capacity:      \([0-9]*\) mWh/\1/g'`
   battery=`echo "100 * $remain_battery / $full_battery" | bc`
   battery="$battery%"
else
   battery="-"
fi

### MAIL
min=`date +'%M'`
mail_check=`echo "$min % 10" | bc`

if [ "$mail_check" -eq 0 ]; then
    mail=`ruby $HOME/bin/mail_checker.rb`
fi



echo 0 widget_tell g_cpu data cpu "$pcpu" | awesome-client
echo 0 widget_tell tb_mem text "$pmem%" | awesome-client
echo 0 widget_tell pb_mem data mem "$pmem" | awesome-client
echo 0 widget_tell tb_date text "$date" | awesome-client
echo 0 widget_tell tb_battery text "$battery" | awesome-client
echo 0 widget_tell tb_mail text "$mail" | awesome-client

sleep 3
done

こちらも awesome-client に標準入力で渡す時にセクション(data やら text)をつけないとダメなのかな。


«前の日記(2008-03-31(月)) 最新 次の日記(2008-04-05(土))» 編集
RSS feed