[Arch]-8-使用conky实现桌面系统信息监控

引言

这篇文章用Arch实例演示如何安装conky,conky是Linux上的桌面系统性能监(zhuang)控(bi)神器,能够嵌入桌面背景,实时监控系统的性能变化。

文章目录

0×1.Arch安装conky

Arch安装:

					 qing@qingsword.com:~$ sudo pacman -S conky
					

Ubuntu安装:

					 qing@qingsword.com:~$ sudo apt install conky-all
					

0×2.conky配置

Arch设置开机启动:

					 qing@qingsword.com:~$ vim ~/.config/autostart/conky.desktop

					   [Desktop Entry]
						Type=Application
						Name=conky
						Exec=conky --daemonize --pause=5
						StartupNotify=false
						Terminal=false
					

界面配置:

					 qing@qingsword.com:~$ vim ~/.conkyrc

					 #具体的配置参数请man conky,部分常用的配置在线都有注释
					e_spacer right
					use_xft yes
					font Microsoft YaHei:size=10
					xftfont Microsoft YaHei:size=10
					override_utf8_locale yes
					update_interval 1
					own_window yes
					own_window_type desktop
					own_window_transparent yes
					#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
					own_window_argb_visual yes
					own_window_argb_value 120
					double_buffer yes
					minimum_size 356 5   #宽度默认356
					maximum_width 600
					draw_shades yes
					draw_outline no
					draw_borders no
					draw_graph_borders no
					default_color ffffff
					default_shade_color 000000
					default_outline_color 000000
					alignment top_right
					gap_x 5
					gap_y 35
					cpu_avg_samples 2
					uppercase no # set to yes if you want all text to be in uppercase

					TEXT
					${alignc}${font Microsoft YaHei:style=Bold:pixelsize=24}${time %H:%M:%S} | ${time %b%d日星期%a}
					${color #ffa200}${hr 2}
					${font Microsoft YaHei:pixelsize=18}
					${color #00ffcf}主机名:${color #00ffcf} ${alignr}${nodename}
					${color #00ffcf}内核: ${color #00ffcf}${alignr}${kernel}
					${color #00ffcf}已运行时间: ${color #00ffcf}${alignr}${uptime}
					${color #ffd700}${stippled_hr 1}
					${font Microsoft YaHei:pixelsize=18}
					${color #00ff1e}CPU占用率% ${alignr}温度 ${alignr}${acpitemp}°C(T)
					${color #00ff1e}CPU 0:${cpu cpu0}%${color #dcff82}${cpubar 8 cpu0}
					${color #ddaa00} ${top name 1}${alignr}${top cpu 1}
					${color lightgrey} ${top name 2}${alignr}${top cpu 2}
					${color lightgrey} ${top name 3}${alignr}${top cpu 3}
					${color lightgrey} ${top name 4}${alignr}${top cpu 4}
					${color #ffd700}${stippled_hr 1}
					${font Microsoft YaHei:pixelsize=18}
					${color #00ff1e}Memory: ${mem} / ${memmax} ${alignr}${color #db7093}${memperc}%
					${color #78af78}${membar 8}
					${color #00ff1e}内存占用: ${alignr} MEM%
					${color #ddaa00} ${top_mem name 1}${alignr} ${top_mem mem 1}
					${color lightgrey} ${top_mem name 2}${alignr} ${top_mem mem 2}
					${color lightgrey} ${top_mem name 3}${alignr} ${top_mem mem 3}
					${color lightgrey} ${top_mem name 4}${alignr} ${top_mem mem 4}
					${color #ffd700}${stippled_hr 1}
					${font Microsoft YaHei:pixelsize=18}
					${color #00ff1e}/ 分区: ${color}${alignr}${fs_used /}/ ${fs_size /}
					${color #78af78}${fs_bar 8 /}
					${color #ffd700}${stippled_hr 1}$color
					${font Microsoft YaHei:pixelsize=18}
					${color #00ff1e}有线网络 $alignr ${color #00ff1e}IP地址: ${color DDAA00}${addr enp3s0}
					${voffset 1}${color #98c2c7} 上传: ${color #db7093}${upspeed enp3s0}/s ${alignr}${color #98c2c7}总共: ${color #db7093}${totalup enp3s0}
					${voffset 1}${color #98c2c7} 下载: ${color #ddaa00}${downspeed enp3s0}/s ${alignr}${color #98c2c7}总共: ${color #ddaa00}${totaldown enp3s0}
					${color #00ff1e}无线网络 $alignr ${color #00ff1e}IP地址: ${color DDAA00}${addr wlo1}
					${voffset 1}${color #98c2c7} 上传: ${color #db7093}${upspeed wlo1}/s ${alignr}${color #98c2c7}总共: ${color #db7093}${totalup wlo1}
					${voffset 1}${color #98c2c7} 下载: ${color #ddaa00}${downspeed wlo1}/s ${alignr}${color #98c2c7}总共: ${color #ddaa00}${totaldown wlo1}
					${color #ffa200}${hr 2}
					

${alignc}代表后面的文字居中显示

${alignr}代表后面的内容靠右显示

${font Microsoft YaHei:style=Bold:pixelsize=24}代表后面的文字用微软雅黑字体,粗体,字体大小24显示

${color #ffa200}代表后面的内容使用#ffa200颜色

${stippled_hr 1} 表示分割线虚线宽度1,${hr 2}表示实线宽度2

所有被支持的系统变量都可以在man conky手册中查找到,变量带入的位置需要使用$符号

剩下的内容大家可以查看man手册的内容自己配置,参考上面的配置文件和英文意思也能大致猜出这些变量的作用,需要注意更改配置文件中的一些系统标识,比如我的无线网卡号是wlo1(配置中${downspeed wlo1} wlo1的位置可以替换成自己的无线网卡的名称),以此类推,希望大家玩的愉(beng)快(kui)。

这里有一个比较详细的参考文档,上面我的配置也放在里面,可以复制:conky.txt