GeekTool配置
一、已登录时间
?
?
uptime | awk '{print "已登录时间 : " $3 " " $4 " " $5 }' | sed -e 's/.$//g'; \
?
二、电池使用情况
?
?
#! /bin/sh## Battery status script, writen for GeekTool usage. Free to# use as you please.## Prints the current charge, time remaining on battery power or the AC# power status# Create array (Capacity,Voltage,Flags,Current,Amperage,Cycle Count)status=(`ioreg -w0 -l|grep LegacyBatteryInfo|sed -e 's/[^1234567890]/ /g'`)# Fix Amperage (convert large number to negative one)status[4]=$(expr ${status[4]} + 0) # if charger connectedif [ $((${status[2]} & 1)) == 1 ]; then #if battery is charging if [ $((${status[2]} & 2)) == 2 ]; then # Calculate minutes until battery is fully charged if [ ${status[4]} -lt 0 ]; then mins='' else mins=`echo "(${status[0]}-${status[3]})*60/${status[4]}"|bc` if [ $mins > 59 ]; then mins=`printf ", %d:%02d until battery is fully charged" $(( mins / 60 )) $(( mins % 60 ))` else mins=`printf ", 0:%02d until battery is fully charged" $mins` fi fi echo `echo "${status[3]}*100/${status[0]}"|bc`"% (charging$mins)" else perc=`echo "${status[3]}*100/${status[0]}"|bc` if [ $prec -lt 100 ]; then echo "$perc% (battery not charging)" else echo "100% (battery is fully charged)" fi fi# if charger not connectedelse # Calculate minutes until empty if [ ${status[4]} -ge 0 ]; then mins='' else mins=`echo "- ${status[3]}*60/${status[4]}"|bc` if [ $mins > 59 ]; then mins=`printf "(%d:%02d remaining on battery)" $(( mins / 60 )) $(( mins % 60 ))` else mins=`printf (0:%02d remaining on battery)" $mins` fi fi echo `echo "${status[3]}*100/${status[0]}"|bc`"%$mins"fi
?
三、内存使用情况
?
?
top -l 1 | awk '/PhysMem/ {print "已使用内存 : " $8 " "}' ; \top -l 1 | awk '/PhysMem/ {print "非活跃内存 : " $6+$10"M"}'
?
四、CPU使用情况
?
?
top -l 2 | awk '/CPU usage/ && NR > 5 {print $1, ":", $3, $4, $5, $6, $7, $8}'
?
五、硬盘使用情况
?
?
df -g | awk '/\/dev\/disk0/ {print $2-$3"G of "$2"G remaining ""("$5")" }';
?
六、废纸篓使用情况
?
?
du -sh ~/.Trash/ | awk '{print "废纸篓 : " $1}'
?
七、网络配置
?
?
myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`if [ "$myen1" != "" ]thenecho "$myen1"elseecho "INACTIVE"fiwip=`curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<"`echo "$wip"
?
八、iTunes当前播放信息
?
首先,在iTunes目录下新建一个名为itunesinfo.scpt的文件,内容如下:
?
?
tell application "System Events"set powerCheck to ((application processes whose (name is equal to "iTunes")) count)if powerCheck = 0 thenreturn ""end ifend telltell application "iTunes"tryset playerstate to (get player state)end tryif playerstate = paused thenset trackPaused to " (paused)"elseset trackPaused to ""end ifif playerstate = stopped thenreturn " "end ifset trackID to the current trackset trackName to the name of trackIDset theStream to the current stream title as textif theStream is not "missing value" thenset totalData to "Stream : " & trackName & trackPaused & "Title : " & theStreamelseset artistName to the artist of trackIDset albumName to the album of trackIDset totalData to "Track : " & trackName & trackPaused & "Artist : " & artistName & "Album : " & albumNameend ifreturn totalDataend tell
?
然后,在GeekTool中写入如下脚本:
?
?
osascript /Users/gaohf/Music/iTunes/itunesinfo.scpt?
九、天气情况
?
#!/bin/shweather=$(curl --silent "http://xml.weather.yahoo.com/forecastrss?p=CHXX0520&u=c" | grep -E '(Current Conditions:|C<BR)' | \ sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//')# doing it this way gets rid of a preceeding blank lineecho ${weather}?
?