|
发表于 2008-3-21 17:23:44
|
显示全部楼层
你的补丁做得不错,不过如果能够同时设置两种字体分别显示英文和中文就更好了。看了一下代码,原来的是用font.set来做到这个的。你的补丁ms只支持设置一种字体(我对xft库不熟悉)。希望你能够继续研究下去。
下面贴一个状态脚本:
- #!/bin/bash
- AWKS_M='/^MemTotal/ {mtotal=$2};
- /^MemFree/ {mfree=$2};
- /^Active/ {mactive=$2};
- /^Cached/ {mcached=$2};
- /^SwapTotal/ {swtotal=$2};
- /^SwapFree/ {swfree=$2};
- /^temperatures/ {temp=$2};
- /^speed/ {fspd=$2};
- /^CPU/ {nu1=$2; nt1=$3; nu2=$4; nt2=$5; ou1=$6; ot1=$7; ou2=$8; ot2=$9;};
- END {
- if (nt1 != "0") print "CPU1:",int((nu1-ou1)/(nt1-ot1)*100) "%";
- if (nt2 != "0") print "CPU2:",int((nu2-ou2)/(nt2-ot2)*100) "%";
- if (temp != "0") print temp "C",fspd "c";
- print "| Mem:",int(((mtotal-mfree)/mtotal)*100) "%","Swap:",int(((swtotal-swfree)/swtotal)*100) "%";}'
-
- AWKS_ST='/cpu0/ {total1=$2+$3+$4+$5; use1=$2+$3+$4};
- /cpu1/ {total2=$2+$3+$4+$5;use2=$2+$3+$4};
- END {
- print use1,total1;
- if (total2 && use2) print use2,total2;
- else print "0 0";
- }
- '
- SLEEP=4
- DATEFMT="+%a %x %H:%M"
-
- INTERFACE=eth0
-
- MEMINFO=/proc/meminfo
- FAN=
- TERM=
- [ -f /proc/acpi/ibm/fan ] && FAN=/proc/acpi/ibm/fan
- [ -f /proc/acpi/ibm/thermal ] && TERM=/proc/acpi/ibm/thermal
-
- OCPU=`awk "$AWKS_ST" /proc/stat`
- RXB=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
- TXB=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`
- while :; do
-
- # get new rx/tx counts
- RXBN=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
- TXBN=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`
- NCPU=`awk "$AWKS_ST" /proc/stat`
-
- # calculate the rates
- # format the values to 4 digit fields
- RXR=$(printf "%4d\n" $(echo "($RXBN - $RXB) / 1024/${SLEEP}" | bc))
- TXR=$(printf "%4d\n" $(echo "($TXBN - $TXB) / 1024/${SLEEP}" | bc))
-
- # print out the rates with some nice formatting
- #MSG=`echo $NCPU $OCPU | awk "$AWKS_CPU"`" "`awk "$AWKS_M" $MEMINFO $FAN ${TERM}`" | ${INTERFACE}: D ${RXR}kB U ${TXR}kB"
- MSG=`(echo -e "CPU: $NCPU ${OCPU}\n"; cat $MEMINFO $FAN ${TERM}) | awk "$AWKS_M"`" | ${INTERFACE}: D ${RXR}kB U ${TXR}kB"
- echo $MSG "|" `date "$DATEFMT"`
-
- # reset old rates
- RXB=$RXBN; TXB=$TXBN; OCPU=$NCPU
-
- sleep $SLEEP
- done
复制代码 可保存为statusbar.sh在.xinitrc文件中能够显示CPU使用率,CPU温度,风扇转速(需要修改/proc文件位置),内存使用率,网络下载速度 |
|