文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>conky的中文天气预报脚本

conky的中文天气预报脚本

时间:2009-03-18  来源:zhenze12345

我把conky的配置文件和天气预报的脚本写在了两篇blog里,其实我的天气预报的温度是由今天的最高气温和明天的最低气温组成的,看着不爽的可以自己改,忘了说了,我脚本里的天气预报是苏州的,看了几天没什么错才贴出来的,脚本我很外行,高手别B4我。还有就是这个脚本与我的贴图有些出入,后来改了很多,天气预报中删除了风向,标题都改成了中文。希望可以给那些想学conky而还没开始学的人一点帮助。

我的脚本都在~/.conky目录下,一共五个脚本

1.cat_hightemp.sh

#!/bin/sh
cat /tmp/high

2.cat_weather.sh

#!/bin/sh
cat /tmp/weather

3.weather.sh(核心的东西都在这里)

sed -i 's/全市//g' /tmp/function2
TMP=`cat /tmp/function2`
let " TMP1 = 0 "
if [ "${#TMP}" -ne "$TMP1" ]
then
 TMP=${TMP#*天气预报<br>}
 TMP=${TMP%%;<br>*}
 echo ${TMP%%。<br>*} > /tmp/weather
 sed -i 's/,/\n/g' /tmp/weather
 sed -i 's/;/\n/g' /tmp/weather
 sed -i 's/今天最高气温/今天最高气温\:/g' /tmp/function2
 TMP=`cat /tmp/function2`
 TMP=${TMP#*今天最高气温:}
 TMP=${TMP#:}
 TMP=${TMP%%左右,*}
 TMP=${TMP#*-}
 TMP=${TMP%%,<br>*}
 echo ${TMP%%。<br>*} > /tmp/high
 TMP=`cat /tmp/function2`
 TMP=${TMP#*明*最低气温:}
 TMP=${TMP%%-*℃*}
 TMP=${TMP%%℃。<br>*}
 echo ${TMP%%℃左右*} > /tmp/low
 TMP=`cat /tmp/function2`
 TMP=${TMP#*。<br>}
 TMP=${TMP%%,<br>*} 
 TMP=${TMP%%<br>今天*}
 echo ${TMP%%。<br>*} > /tmp/wind
 sed -i 's/,/\n/g' /tmp/wind
 sed -i 's/。//g' /tmp/wind
 TMP=`cat /tmp/low`
 echo -n $TMP >> /tmp/weather
 echo -n "-" >> /tmp/weather
 TMP=`cat /tmp/high`
 echo $TMP >> /tmp/weather
 cat /tmp/wind >> /tmp/weather 
fi

4.cat_lowtemp.sh

#!/bin/sh
cat /tmp/low

5.rm.sh

#!/bin/sh
rm /tmp/{high,low,weather,function1.asp,function2}

相关阅读 更多 +
排行榜 更多 +
火柴人联盟2腾讯qq登录版

火柴人联盟2腾讯qq登录版

体育竞技 下载
tsuki odyssey游戏(月兔冒险奥德赛)

tsuki odyssey游戏(月兔冒险奥德赛)

休闲益智 下载
超级飞侠大冒险

超级飞侠大冒险

休闲益智 下载