您的位置:首页 > 其它

ubuntu 14.04 添加 CPU 温度 在面板标题栏上

2014-08-08 21:48 375 查看
http://tieba.baidu.com/p/3005287033
http://a-nerd.info/?p=1377
首先当然是用wget下载indicator-sysmonitor,终端执行命令:wget -c https://launchpad.net/indicator-sysmonitor/trunk/4.0/+download/indicator-sysmonitor_0.4.3_all.deb

下载好后,先不要急于安装,因为软件有些依赖关系还没解决。终端执行:sudo apt-get install python python-psutil python-appindicator 安装依赖。sudo dpkg -i indicator-sysmonitor_0.4.3_all.deb 安装indicator-sysmonitor 。

这样要安装的都安装好了,但是还需要进行一些配置,才能正常显示。由于软件默认显示图标是 sysmonitor.svg,而在 Ubuntu 14.04 64位系统中没有这个图标,这导致图标显示错误,很不美观。于是要把软件默认使用的图标改成一个存在的图标,当然也可以自己动手***一个图标。但是系统中已经有很多图标了,找个好点的直接用上就行!

系统图标存放在:/usr/share/icons/Humanity/apps/ XX目录下(XX 为:128 16 192 22 24 32 48 64 中任一个,对应同一图标的不同尺寸,同一图标并不是每个尺寸都有)。打开/usr/share/icons/Humanity/apps/32 ,发现application-community.svg 还不错,所以我就用这个图标了!当然用其他的或者自己***也是可以的!

找到喜欢的图标后,记下图标的文件名(不包括后缀),这里是 application-community,下面开始进行替换。终端执行命令:sudo
gedit /usr/bin/indicator-sysmonitor

将 724 行的 sysmonitor 改为刚才记下的 application-community

#!/bin/bash

#settings:
netspeed=true
ram=true
cpu=true
temp=true
#-------------------------------------------------------

#---------------- initialize ---------------------------
rm /tmp/.sysmon > /dev/null 2>&1
dstat --net --mem --cpu --output=/tmp/.sysmon 1 1 > /dev/null 2>&1

#----------- up/down speed -----------------------------
if [ $netspeed = true ]; then

upspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1024 | bc)

upkbmb=$(if [ $upspeed -gt 1024 ]; then 
		up1=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1024/1024 | bc -l)
		echo $up1 | head -c 4
	else 
		echo $upspeed | head -c 3
	fi)

downspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1024 | bc)

downkbmb=$(if [ $downspeed -gt 1024 ]; then 
		down1=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1024/1024 | bc -l)
		echo $down1 | head -c 4
	else 
		echo $downspeed | head -c 3
	fi)
#---------------- up/down speed unit --------------------
upunit=$(if [ $upspeed -gt 1024 ]; then echo "MiB/s"; else echo "KiB/s"; fi)
downunit=$(if [ $downspeed -gt 1024 ]; then echo "MiB/s"; else echo "KiB/s"; fi)

fi

#------------------- CPU % used -------------------------
if [ $cpu = true ]; then

cpufree=$(cat /tmp/.sysmon | tail -1 | cut -d ',' -f9)
cpuused=$(echo 100-$cpufree | bc | sed -e 's/\..*//')

fi

#------------------- RAM % used --------------------------
if [ $ram = true ]; then

memused=$(free -m | grep buffers/cache | tr -s ' ' | cut -d' ' -f 3)
memfree=$(free -m | grep buffers/cache | tr -s ' ' | cut -d' ' -f 4)
memtotal=$(echo $memused+$memfree | bc -l)

memusedpercent=$(echo 100-100*$memfree/$memtotal | bc)

fi

#------------------- acpitemp --------------------------
if [ $temp = true ]; then
#将acpi -t这个命令显示出第16-20个字符赋给acpitemp

acpitemp=$(acpi -t| cut -c 16-20)°C

fi

#------------------ The Indicator Sysmonitor actual output -
echo $(if [ $ram = true ]; then echo M:$memusedpercent% ; fi) $(if [ $cpu = true ]; then echo C: $cpuused% ; fi) $(if [ $netspeed = true ]; then echo ↑$upkbmb $upunit  ↓$downkbmb $downunit; fi)$(if [ $temp = true ]; then echo T:$acpitemp; fi)
#当temp为True时显示CPU温度


sudo apt-get install dstat

sudo apt-get install acpi

下载sysmon文件,放入主目录,重命名为.sysmon,在设置界面按下图配置,Customize
output中有{sysmon}就可以



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: