Ubuntu下conky 的风扇转速和显卡温度显示问题的解决办法

系统:ubuntu10.04
笔记本:Thinkpad R400
显卡:ATI 3400
问题:安装完conky后,显示CPU温度等信息正常,但显示不了风扇的转速和显卡的温度,网上找了一些解决的办法,悲剧的是我运行aticonfig --adgt命令时报错。无法获取显卡温度,风扇转速的问题也没有找到解决的办法,琢磨了一下午,终于找到了解决的办法。
获取显卡温度时报错如下:ERROR - Get temperature failed for the Default Adapter - ATI Mobility Radeon HD 3400 Series
我们知道,conky获取系统信息时是通过获取系统文件的一些特殊字段来获取信息的,换句话说,conky是一个平台,我们要做的就是把所要监控的信息接入这个平台,而调取这些信息都是通过系统本身的命令来完成的,这时就显示了conky强大的功能了,几乎可以显示你想显示的所有系统信息,当然,前提是你知道如何调用这些信息,在编辑conky配置文件时,你需要对管道等linux下的概念很熟悉,同时,对grep,cut等命令的用法很熟悉,这点是非常重要的。
网上很多针对获取A卡温度的方法是调用显卡驱动本身的aticonfig --odgt命令来完成的,这确实是最好的办法,但在这种办法失效的情况下,就只有另寻别的办法了,以下是我的配置文件,我是通过sensors这个监控程序,来获取显卡的温度和风扇的转速,然后conky通过调取sensors所获得的信息的相关字段来获得风扇的转速和显卡的温度,以下是我的conky配置文件。有一点需要说明的是该配置文件参考借鉴了http://forum.ubuntu.org.cn/viewtopic.php?t=271567上的一篇文章,显示风扇转速和显卡温度是我自己加进去的,同时修改了显示器亮度的配置。在此对作者表示感谢。
# -*- conf -*-
#
# ~/.conkyrc - Conky configuration file

# do not fork to background
background no
# font settings
use_xft yes
font Comic Sans MS-8
uppercase no

# update every 3 secs
update_interval 2

# stay running forever
total_run_times 0

# draw to root window
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# avoid flickering
double_buffer yes

# size
minimum_size 400 100
maximum_width 1280

# position
alignment top_left
gap_x 0
gap_y 0

# colors
default_color white
default_shade_color black
default_outline_color black
color0 000000
color1 144556
color2 33b0dc

# borders
draw_borders no
stippled_borders 8
border_margin 4
border_width 1

# shades
draw_shades no

# outline
draw_outline no

# spacer
use_spacer no

# buffers
no_buffers yes

# sampling
cpu_avg_samples 2
net_avg_samples 2

# configuration
TEXT
${voffset 35}${offset 95}${color2}System
${offset 95}$color1 CPU: $color2 ${execi 99999 cat /proc/cpuinfo | grep "model name" -m1 | cut -d":" -f2 | cut -d" " -f2- | sed 's#Processor ##'}
${offset 95}$color1 System: $color2 ${execi 99999 lsb_release -d -s -c | tr -s "\n" " "} $kernel
${offset 95}$color1 Uptime:$color2 $uptime $color1 Load:$color2 $loadavg

${voffset -60}${offset 655}${color2}Display: Lenovo Thinkpad LCD (1280*800)
${offset 655}$color2 Brightness $color2${exec cat /proc/acpi/video/VID1/LCD0/brightness | grep current}%

${voffset 85}${offset 95}${color2}CPU 1
${offset 95}$color1 Usage: $color2${cpu cpu1}% $color1 Temperature:$color2 $acpitemp ${font iYaHei:size=8}℃
${offset 95}${font}$color1 Load: $color2$cpu% ${cpubar cpu0 6,200}
${offset 95}$color1 ${cpugraph cpu0 20,270 000000 33b0dc}
${offset 95}${color2}CPU 2
${offset 95}$color1 Usage: $color2${cpu cpu2}% $color1 Temperature:$color2 $acpitemp ${font iYaHei:size=8}℃
${offset 95}${font}$color1 Load: $color2$cpu% ${cpubar cpu1 6,200}
${offset 95}$color1 ${cpugraph cpu1 20,270 000000 33b0dc}
${offset 95}${color2}FAN: $color1${execi 300 /usr/bin/sensors | grep fan | cut -c11-17}rpm      #获取风扇转速
${offset 95}${color2}GPU:  $color1${execi 300 /usr/bin/sensors | grep temp4 | cut -c15-16}℃      #获取显卡温度
${offset 95}${color2}HDD: $color1${hddtemp /dev/sda}℃    #获取硬盘温度,实际上也可通过获取显卡温度的方法获取硬盘温度,只是该方法比较方便。

${voffset 35}${offset 95}${color2}Wireless (${wireless_essid wlan0})
${offset 95}$color1 IPv4: $color2${addr wlan0} ${color #144556} WLAN quality: $color2${wireless_link_qual_perc wlan0}% ${wireless_link_bar 5, 40 wlan0}
${offset 95}$color1 Down: $color2${downspeed wlan0} /s $color1 ${downspeedgraph wlan0 8,100 000000 33b0dc} $color1 Up:$color2 ${upspeed wlan0} /s $color1 ${upspeedgraph wlan0 8,100 000000 33b0dc}
${offset 95}${color2}Wire
${offset 95}$color1 IPv4: $color2${addr eth0}
${offset 95}$color1 Down: $color2${downspeed eth0}/s $color1 ${downspeedgraph eth0 8,100 000000 33b0dc} $color1 Up:$color2 ${upspeed eth0} /s $color1 ${upspeedgraph eth0 8,100 000000 33b0dc}

${voffset -430}${offset 1100}
${voffset 460}${offset 1120}$color2 ${font}Battery: $color2 ${battery_percent BAT0}% ${battery_bar BAT0}
${offset 1120}$color1 State: $color2$acpiacadapter

${voffset 30}${offset 1010}${color2}File System (${fs_type /})
${offset 1010}$color1 Total:$color2 ${fs_size /} $color1 Free:$color2 ${fs_free /} ${fs_used_perc /}%
${offset 1010}$color1 Usage:$color2 ${fs_bar 5,170 /}
${offset 1010}${color2}/home (ext4)
${offset 1010}$color1 Total:$color2 ${fs_size /home} $color1 Free:$color2 ${fs_free /home} ${fs_used_perc /home}%
${offset 1010}$color1 Usage:$color2 ${fs_bar 5,170 /home}
${offset 1010}${color2}/boot (ext4)
${offset 1010}$color1 Total:$color2 ${fs_size /boot} $color1 Free:$color2 ${fs_free /boot} ${fs_used_perc /boot}%
${offset 1010}$color1 Usage:$color2 ${fs_bar 5,170 /boot}

${voffset -10}${offset 400}${color1}Memory ${color2}($memmax)
${offset 400}${color1}RAM: $color2$mem($memperc%) ${membar 5,142}
${offset 400}${color1}Swap: $color2$swap ($swapperc%) ${membar 5,142}


${voffset -150}${offset 100}${color1}Processes: $color2$processes $color1 Runing:$color2${tcp_portmon 1 65535 count}
${offset 100}${color2}Name              PID     CPU%   MEM%
${offset 100}${color1} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${offset 100}${color1} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${offset 100}${color1} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}

${offset 100}${color2}Mem usage
${offset 100}${color1} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${offset 100}${color1} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${offset 100}${color1} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
显示效果如图(因上传图片大小限制,故为局部图,全图基本和http://forum.ubuntu.org.cn/viewtopic.php?t=271567上的图片差不多,区别主要在风扇转速和显卡温度的显示上)





你可能感兴趣的:(ubuntu,ThinkPad,conky,风扇转速,显卡温度)