CONKY
原文
http://www.ubuntu-tw.org/
modules/newbb/viewtopic.php?viewmode=thread&topic_id=35948&forum=19
一、安裝套件並設定登入時啟動
請在終端機中依序輸入下列指令
sudo apt-get install conky
mkdir -p ~/.conky/default/
cp /etc/conky/conky.conf ~/.conky/default/
然後到「系統>偏好設定>始動應用程式」加入以下內容
名稱:Conky
指令:conky -c /home/用戶名稱/.conky/default/conky.conf
其中「用戶名稱」請代換成你的用戶名稱
如果你從網路上下載了別的Conky設定檔
請將「/home/用戶名稱/.conky/default/conky.conf」換成該設定檔的路徑、檔名
二、調整設定檔的基本設定
請在終端機中輸入
gedit ~/.conky/default/conky.conf 或你從網路下載下來的Conky設定檔的路徑、檔名
請將「alignment」的值改為「 top_right」 或者你想要的
top_right是靠右上 alignment top_left是靠左上 bottom_right是靠右下
bottom_left是靠左下
請將「gap_x」的值改為「10」 或者你想要的
這是離水平邊緣的距離
請將「gap_y」的值改為「35」 或者你想要的
這是離垂直邊緣的距離
請將「own_window_type」的值改為「normal」
並換行後加入下面這一行 這樣可以讓Conky不會有圖層覆蓋方面的問題
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
還有加入下一行可以改善閃爍
double_buffer yes
三、調整設定檔的美觀設定
請將「xftfont DejaVu Sans Mono:size=12」改為「xftfont Monospace:size=10」
或想使用的字型名稱與字型大小 注意字型名稱若選用沒有中文字的字型檔 將無法顯示
中文
若要改變預設的字型顏色 請在「default_color」設定想要的顏色
設定值請打顏色名稱或RGB值 例如:white或ffffff
假如想替字型加上陰影 請將「draw_shades」的值改為「yes」
並在「default_shade_color」設定顏色
或者如果想替字型加上描邊(但是「陰影」會被遮住) 請將「draw_outline」的值改為
「yes」
並在「default_outline_color」設定顏色
假如想顯示邊框 請將「請將「draw_borders」的值改為「yes」
而「border_width」可以決定邊框的粗細
並且若把「stippled_borders」的值設為大於「0」便能成為虛線
如果想更換底色請加入下面這一行 「black」請換為你想要的顏色的名稱或RGB值
own_window_colour black
而加入下面三行可以使底色透明化(需視窗管理器有支援RGBA)
第二行的數值0全透明到255不透明 第三行可以決定是否去掉底色
own_window_argb_visual yes
own_window_argb_value 128
own_window_transparent no
own_window_type」若設「override」則會與「own_window_argb_visual」衝突)
增加 CPU 溫度監控
1. 安裝lm-sensors
sudo apt-get install lm-sensors
2. 設定監控選項
sensors-detect
全部回答 yes 即可
.....(YES/no) ← 也就是預設都按 enter 它就幫你回答 yes
但需註意最後的一個問題,它預設的回答是 no
.....(yes/NO) ← 這裡你要自己手動輸入 yes 之後按 enter 才行
這行的問題是問你它要自動幫你加入設定檔可不可以,回答 yes 之後重開機即可
3.重開機
重開機之後輸入 sensors 指令,就會看到類似以下的資訊
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +47.0°C (high = +72.0°C, crit = +100.0°C)
coretemp-isa-0001
Adapter: ISA adapter
Core 1: +39.0°C (high = +72.0°C, crit = +100.0°C)
coretemp-isa-0002
Adapter: ISA adapter
Core 2: +37.0°C (high = +72.0°C, crit = +100.0°C)
coretemp-isa-0003
Adapter: ISA adapter
Core 3: +43.0°C (high = +72.0°C, crit = +100.0°C)
以上就是系統偵測到的4核心的 CPU 溫度
我們需要寫個小程式語法來抓到 CPU 溫度的數字
sensors | grep "Core 0:" | cut -d+ -f2 | cut -c1-7
grep "Core 0:" 是說截取 Core 0: 這一整行文字
cut -d+ -f2 -d+ 是說以"+"為間隔字元, -f2 取第2段文字
Core 0: +47.0°C (high = +72.0°C, crit = +100.0°C)
第1段 ↑ 第2段 ↑ 第3段 ↑ 第4段文字
cut -c1-7 以字元為單位,取1到7的字元,所以就會取出 47.0°C 這 樣的資料
這部份你就要反覆的測試之後,正確的取出數字之後,我們才能接著往下做
以下是我把 CPU 使用率的部份結合 CPU 溫度一起顯示的設定語法
${color #98c2c7}CPU1使用率: ${cpu cpu1}% ${color #db7093}${alignr}溫度: ${execi 6 sensors | grep "Core 0:" | cut -d+ -f2 | cut -c1-7}
${color #78af78}${cpubar cpu1}
${color #98c2c7}CPU2使用率: ${cpu cpu2}% ${color #db7093}${alignr}溫度: ${execi 6 sensors | grep "Core 1:" | cut -d+ -f2 | cut -c1-7}
${color #78af78}${cpubar cpu2}
${color #98c2c7}CPU3使用率: ${cpu cpu3}% ${color #db7093}${alignr}溫度: ${execi 6 sensors | grep "Core 2:" | cut -d+ -f2 | cut -c1-7}
${color #78af78}${cpubar cpu3}
${color #98c2c7}CPU4使用率: ${cpu cpu4}% ${color #db7093}${alignr}溫度: ${execi 6 sensors | grep "Core 3:" | cut -d+ -f2 | cut -c1-7}
${color #78af78}${cpubar cpu4}
硬碟使用量
${voffset 10}${font Sans:size=14}HARDDISK${font} ${alignr}${voffset -8}${outlinecolor 000000}${color ffffff}${diskiograph 14,90}${color}${outlinecolor}
${voffset 10}Home: ${alignr} ${fs_used /home} + ${fs_free /home}
${voffset 5}${offset 10}${fs_size /home} ${alignr}${outlinecolor 000000}${color ffffff}${fs_bar 10,115 /home}${color}${outlinecolor}
目前設定
# Conky, a system monitor, based on torsmo
#
# Any original torsmo code is licensed under the BSD license
#
# All code written since the fork of torsmo is licensed under the GPL
#
# Please see COPYING for details
#
# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
alignment top_right
background no
border_width 1
cpu_avg_samples 2
default_color white
default_outline_color white
default_shade_color white
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
use_xft yes
xftfont DejaVu Sans Mono:size=8
gap_x 0
gap_y 75
minimum_size 220 700
net_avg_samples 2
no_buffers yes
double_buffer yes
out_to_console no
out_to_stderr no
extra_newline no
own_window yes
own_window_class Conky
own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer none
show_graph_scale no
show_graph_range no
own_window_argb_visual yes
own_window_argb_value 128
own_window_transparent no
override_utf8_locale yes
TEXT
${font Sans:size=14}SYSTEM${font} ${alignr}Uptime: ${uptime}
${color ffffff}${font AR PL UMing TW:size=11:style=Bold}${time %b%d日 星期%a}${alignr}${time %p%l:%M:%S}
${font Sans:size=8}${voffset 10}CPU1: ${execi 6 sensors | grep "Core 0:" | cut -d+ -f2 | cut -c1-7} ${alignr}${cpu cpu1}% ${outlinecolor 000000}${color ffffff}${cpubar cpu1 8,65}${color}${outlinecolor}
CPU2: ${execi 6 sensors | grep "Core 1:" | cut -d+ -f2 | cut -c1-7} ${alignr}${cpu cpu2}% ${outlinecolor 000000}${color ffffff}${cpubar cpu2 8,65}${color}${outlinecolor}
RAM: ${memperc}% ${alignr}${outlinecolor 000000}${color ffffff}${membar 8,100}${color}${outlinecolor}
SWAP: ${swapperc}% ${alignr}${outlinecolor 000000}${color ffffff}${swapbar 8,100}${color}${outlinecolor}
${voffset 5}CPU Fan: ${alignr}${execi 6 sensors | grep "fan1:" | cut -c13-20}
GPU Fan: ${alignr}${execi 6 sensors | grep "fan3:" | cut -c13-20}
${voffset 10}${font Sans:size=14} TOP CPU & TOP MEM${font}
${voffset 10}${font Monospace:size=6}PID${offset 21}COMMAND${alignr}%CPU${font}
${voffset 5}${top pid 1} ${top name 1}${alignr}${top cpu 1}
${top pid 2} ${top name 2}${alignr}${top cpu 2}
${top pid 3} ${top name 3}${alignr}${top cpu 3}
${top pid 4} ${top name 4}${alignr}${top cpu 4}
${voffset 10}${font Monospace:size=6}PID${offset 21}COMMAND${alignr}%MEM${font}
${voffset 5}${top_mem pid 1} ${top_mem name 1}${alignr}${top_mem mem 1}
${top_mem pid 2} ${top_mem name 2}${alignr}${top_mem mem 2}
${top_mem pid 3} ${top_mem name 3}${alignr}${top_mem mem 3}
${top_mem pid 4} ${top_mem name 4}${alignr}${top_mem mem 4}
${voffset 10}${font Sans:size=14}HARDDISK${font} ${alignr}${voffset -8}${outlinecolor 000000}${color ffffff}${diskiograph 14,90}${color}${outlinecolor}
${voffset 10}Home: ${alignr} ${fs_used /home} + ${fs_free /home}
${voffset 5}${offset 10}${fs_size /home} ${alignr}${outlinecolor 000000}${color ffffff}${fs_bar 10,115 /home}${color}${outlinecolor}
${voffset 10}${font Sans:size=14}xDSL${font} ${alignr}IP: ${addr eth0}
${voffset 11}Up: ${alignr 8}${voffset -1}${font Monospace:size=9}${upspeed eth0}/s${font} ↑
${voffset 1}Down: ${alignr 8}${voffset -1}${font Monospace:size=9}${downspeed eth0}/s${font} ↓
${voffset 10}${font Sans:size=14}TCP Connect${font} ${alignr}Total: ${tcp_portmon 1 65535 count}
${voffset 10}${font Monospace:size=6}IP Port ${alignr}Service${font}
${voffset 5}${tcp_portmon 1 65535 rip 0} ${tcp_portmon 1 65535 rport 0} ${alignr}${tcp_portmon 1 65535 rservice 0}
${tcp_portmon 1 65535 rip 1} ${tcp_portmon 1 65535 rport 1} ${alignr}${tcp_portmon 1 65535 rservice 1}
${tcp_portmon 1 65535 rip 2} ${tcp_portmon 1 65535 rport 2} ${alignr}${tcp_portmon 1 65535 rservice 2}
${tcp_portmon 1 65535 rip 3} ${tcp_portmon 1 65535 rport 3} ${alignr}${tcp_portmon 1 65535 rservice 3}
${tcp_portmon 1 65535 rip 4} ${tcp_portmon 1 65535 rport 4} ${alignr}${tcp_portmon 1 65535 rservice 4}
${tcp_portmon 1 65535 rip 5} ${tcp_portmon 1 65535 rport 5} ${alignr}${tcp_portmon 1 65535 rservice 5}
${tcp_portmon 1 65535 rip 6} ${tcp_portmon 1 65535 rport 6} ${alignr}${tcp_portmon 1 65535 rservice 6}
沒有留言:
張貼留言