当前位置:   article > 正文

Ubuntu在标题栏显示CPU、内存、网速和温度_indicator-sysmonitor 温度

indicator-sysmonitor 温度

1. 安装System Monitor Indicator:
sudo add-apt-repository ppa:alexeftimie/ppa
sudo apt-get update
sudo apt-get install indicator-sysmonitor
2. 默认只显示CPU、内存,要显示上下行网速和温度的话需要安装另外两个东西:
sudo apt-get install dstat
sudo apt-get install acpi
3. 从链接 http://anerd.sourceforge.net/a-nerd.info/Indicator-Sysmonitor-Show-Nework_speed-&-CPU-Temp/sysmon下载 sysmon文件,放入主目录,重命名为.sysmon。如果上面的链接下载不了,可以新建个sysmon文件,把下面的源代码复制过去:
#!/bin/bash

#settings:
netspeed=true
ram=true
cpu=true
temp=false
#---------------- 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
#------------------- CPU °C Temp-------------------------
if [ $temp = true ]; then
cputemp=$(acpi -t | cut -c 16-20)°C
fi  
#------------------ The Indicator Sysmonitor actual output -
echo $(if [ $cpu = true ]; then echo CPU: $cpuused% \|; fi) $(if [ $ram = true ]; then echo Mem: $memusedpercent% \|; fi) $(if [ $temp = true ]; then echo Temp: $cputemp \|; fi)  $(if [ $netspeed = true ]; then echo ↑ $upkbmb $upunit  ↓ $downkbmb $downunit; fi)
然后settings中想显示的设为true,不想显示的设为false。
4. 找到System Monitor Indicator的设置,按下图配置,Customize output中有{sysmon}就可以:

5. 由于软件默认显示图标是 sysmonitor.svg,而在 Ubuntu 14.04 系统中没有这个图标,就会导致图标显示错误,很不美观。我们可以把软件默认使用的图标改成一个存在的图标,当然也可以自己动手制作一个图标。但是系统中已经有很多图标了,找个好点的直接用上就行!
系统图标存放在 /usr/share/icons/Humanity/apps/XX目录下(XX 为:128、16、192、22、24、32、48、64中任意一个,对应同一图标的不同尺寸,同一图标并不是每个尺寸都有,其中48的最多)。例如打开/usr/share/icons/Humanity/apps/48,发现 utilities-system-monitor.svg 还不错,我就用这个图标,当然用其他的或者自己制作也是可以的。
找到喜欢的图标后,记下图标的文件名(不包括后缀),下面开始进行替换。终端执行命令:
sudo gedit /usr/bin/indicator-sysmonitor
将 724 行的 sysmonitor 改为刚才记下的utilities-system-monitor


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/310448
推荐阅读
相关标签
  

闽ICP备14008679号