ubuntu下一个非常漂亮的conky主题

据说这款conky主题与ubuntu10.04的默认主题是绝配,试了一下,确实不错,并且自己定制了一下,就贴出来。

参考:推荐一款conky配置,与ubuntu10.04主题绝配

1、安装conky
首先要安装conky和curl(curl这个工具非常好用,它和php的libcurl是一家的,用它就可以模拟一个浏览器,这样发在脚本中就能作很多事情哦^_^)

[code]
sudo apt-get install conky
sudo apt-get install curl
[/code]

2、安装主题
原始主题可以到gnome-look网站下载。
不过奇怪的是,它的配置文件conkyrc里面用到了一个脚本./scripts/ip.sh,而主题包中确没给出,网上搜了一下发现这个文件很简单,你可以自己创建这个文件,把bah代码贴出来,如下:

[code]
#! /bin/sh
curl icanhazip.com
exit
[/code]

可见只是一条命令而已,它的意思是用curl来访问icanhazip.com这个网站,网页内容很简单,就是你的ip地址,可以在浏览器里访问看看。

把主题文件解压,解压出来是个隐藏文件,按Ctrl+H显示它,把它移到你的主目录下,这样就安装好主题了。

3、运行conky

  1. 命令行下
  2. [code]conky -c $HOME/.conkytheme/conkyrc [/code]

  3. 在桌面创建一个启动程序
  4. 在桌面上右击鼠标,选择Create Launcher,对话框中,name 填 conky,comman 填 conky -c /home/jarson/.conkytheme/conkyrc,把jarson换成自己的用户名,还可以给它选择一个图标。

  5. 开机自动启动
  6. 类似第2种方法。
    “系统”->“首选项”->“启动应用程序”->“添加”
    名称:conky
    命令:conky -c /home/jarson/.conkytheme/conkyrc

上面的是安装方法,下面贴出我修改后的conkyc文件:

[code]
# Locale, fonts and font sizes.
use_xft yes
xftfont Droid Sans:size=9
override_utf8_locale yes

# Conky performance
update_interval 1
total_run_times 0
double_buffer yes
no_buffers yes
net_avg_samples 2
text_buffer_size 1024

# Execute it in its own window
own_window yes
own_window_transparent yes
#reference to http://blog.chinaunix.net/u3/109488/showart_2256719.html
#own_window_type panel
own_window_type override
#own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Borders, margins.
draw_borders no
#border_margin 1

# Own window color
own_window_colour 393834

# Font colors
default_color B7B2AD
#default_color EFEEED

# Text shadows
draw_shades no

# Header colors
color0 DD3A21

# Minimum dimensions
minimum_size 1440 0

# Conky positioning.
alignment bottom_left
#alignment top_left
gap_x 0
gap_y 30

# Output
TEXT
${image ~/.conkytheme/pix/frame.png -p 0,0 -s 1280x180}
${voffset 20}${font Droid Sans:style=Bold:size=12}${color0}${goto 180}Disks:${goto 470}Network:${goto 668}Temperatures:${goto 818} Process: ${goto 1064}Time and Date:${font}${color}
${voffset 6}${goto 180}System (/):${goto 260} ${fs_bar 10,80 /}${goto 360}${fs_used /} / ${fs_size /}${goto 470}Upspeed: ${goto 562}${upspeedgraph eth0 10,50 B7B2AD B7B2AD}${font Droid Sans:style=Bold:size=9} ${upspeed eth0}${font}${goto 668}CPU: ${goto 768}${execi 3 sensors | grep -A 0 'temp1' | cut -c15-22} ${goto 818}${color0}${processes}${color} processes${goto 940}${color0}${threads}${color} threads${goto 1064}${time %H:%M} ${time %d/%m/%Y}
${goto 15}Kernel: ${goto 65}${kernel}${goto 180}Home (/Home):${goto 260} ${fs_bar 10,80 /home}${goto 360}${fs_used /home} / ${fs_size /home}${goto 470}Downspeed: ${goto 562}${downspeedgraph eth0 10,50 B7B2AD B7B2AD}${font Droid Sans:style=Bold:size=9} ${downspeed eth0}${font}${goto 668}Hard Disk(sda): ${goto 768}${hddtemp /dev/sda} 潞C ${goto 818}${color4}cpu rank ${goto 940}mem rank${color}${goto 1064}${time %A}, ${time %d} ${time %B} ${time %Y}
${goto 15}CPU: ${goto 65}${cpubar cpu1 10,75}${font Droid Sans:style=Bold:size=9} ${cpu cpu1}%${font}${goto 180}Shares (sdb7):${goto 260} ${fs_bar 10,80 /home/wangbo/LocalShares}${goto 360}${fs_used /home/wangbo/LocalShares} / ${fs_size /home/wangbo/LocalShares}${goto 470}Total Uploaded: ${goto 562}${totalup eth0} ${goto 668}Hard Disk(sdb): ${goto 768}${hddtemp /dev/sdb} 潞C${goto 818}${color0}${top name 1}${color} ${goto 940}${color0}${top_mem name 1}${color}
${goto 15}RAM: ${goto 65}${membar 10,75}${font Droid Sans:style=Bold:size=9} $memperc%${font}${goto 470}Total Download: ${goto 562}${totaldown eth0}${goto 818}${top name 2} ${goto 940}${top_mem name 2}
${goto 15}SWAP:${goto 65}${swapbar 10,75}${font Droid Sans:style=Bold:size=9} $swapperc%${font}${goto 470}Local IP: ${goto 562}${addr eth0}${goto 818}${top name 3}${goto 940}${top_mem name 3}
${goto 15}Uptime: ${goto 65}${uptime}${goto 470}Public IP:${execi 300 curl -s http://whatismyipaddress.com/ > /tmp/myipinformation} ${goto 562}${execi 300 cat /tmp/myipinformation | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'|head -n1}${goto 818}${top name 4} ${goto 940}${top_mem name 4}
${font Droid Sans:style=Bold:size=12}${color0}${goto 15}Network Information: ${font}${color}${color 00ff00} ISP: ${color}${execi 300 cat /tmp/myipinformation | grep 'ISP:'| sed -e 's/.*<td>//g' | sed -e 's/<.*//g'} ${color 00ff00} Connection: ${color} ${execi 300 cat /tmp/myipinformation | grep 'Connection:'| sed -e 's/.*">//g' | sed -e 's/<.*//g'}${color 00ff00} City: ${color}${execi 300 cat /tmp/myipinformation | grep 'City:'| sed -e 's/.*<td>//g' | sed -e 's/<.*//g'} ${color 00ff00} Region: ${color}${execi 300 cat /tmp/myipinformation | grep 'Region:'| sed -e 's/.*<td>//g' | sed -e 's/<.*//g' } ${color 00ff00} Country: ${color}${execi 300 cat /tmp/myipinformation | grep 'Country:'| sed -e 's/.*<td>//g' | sed -e 's/<.*//g'}${execi 300 rm /tmp/myipinformation}
[/code]

我的说明:
修改后的conky配置文件就不需要ip.sh脚本了,直接使用curl命令,并且ip的信息也更加详细,包括地理位置、isp商、接入方式等,方法是直接用curl访问http://whatismyipaddress.com/(因为icanhazip.com有时会挂掉,且信息不完整),将网页内容保存为/tmp/myipinformation,然后用grep和sed工具提取里面的信息,用完之后删除/tmp/myipinformation,这样做速度还是不错的。还增加了进程和内存信息,显示总进程数,总线程数,分别显示利用cpu和内存最多的前5个进程。还对显示温度的部分进行了修改,硬盘温度用hddtemp(因为我的用sensor无法检测)。另外对整个布局进行了调整。

这是修改前的效果(这个图片是别人贴出来的):

conky主题
这是修改后的效果:

conky主题

注意:
在debain系统下hddtemp默认没有以daemon形式运行,这样conky里的配置就无效,解决方法在这里

更新:

由于whatismyipaddress.com现在封了curl这种agent,所以必须自己造一个agent,来欺骗它。方法,将原来curl -s http://whatismyipaddress.com/ > /tmp/myipinformation改为curl -A “Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)” -s http://whatismyipaddress.com/ > /tmp/myipinformation,-A后的参数就是agent参数,自己改成喜欢的就行。

3 thoughts on “ubuntu下一个非常漂亮的conky主题

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>