2013年1月21日 星期一

conky 與 conkywx 配置

conky 主要的功能是在桌面上顯示系統資訊,當然也可以顯示其他有趣的資訊。先安裝吧:

$ yaourt -S conky conkywx

說明文件在這裡

安裝後,就要設定配置檔。google 一下,滿坑滿谷的 screenshot 和 config,只要有想象力,時間,在加上一些耐性,一定可以作出符合自己需要的桌面。

預設的配置檔是放在 $HOME/.conkyrc。在 /etc/conky/conky.conf 這裡有個範例,不過,應該不會有人不改就套用吧。

我是把配置檔放在 ~/.conkyrc,方便未來備份。配置檔很長,放在本文的最後。

conkywx是用來顯示天氣狀況。至少需要兩個檔案:

  • ~/.config/conkywx/conkywx.conf
  • ~/.config/conkywx/template.sh

在 .conkyrc 中用下面的方法連接過去。

template0 "/usr/bin/conkywx"
template1 "/home/mario/.config/conkywx/conkywx.conf"
template2 "/home/mario/.config/conkywx/wx-wu-font-slim-template.sh"

${execpi 7200 ${template0} -c ${template1} -t ${template2}}

conkywx.conf 中設定以下 2 個參數

  • use_xml=0
  • Location=46696

就可以看到松山機場的天氣狀況。其他的地方如下:

conkywx station id

TAIWAN 27-DEC-01
TAIPEI TAOYUAN RCTP 46686 25 04N 121 13E 33 X T 6 TW

MAZU RCFG 46689 26 10N 119 55E 91 X T 7 TW

SUNGSHAN/TAIPEI RCSS 46696 25 04N 121 32E 6 X T 6 TW

TAOYUAN AB RCGM 46697 25 04N 121 13E 45 X 7 TW

DONGSHI RCNO 46730 23 16N 119 40E 45 X 7 TW

MAKUNG AB RCQC 46734 23 34N 119 37E 31 X 7 TW

CHINMEM/SHATOU RCBS 46736 24 25N 118 22E 9 X T 6 TW

PA KUEI/BAKUAI RCUK 46738 24 55N 121 17E 141 X 7 TW

KAOHSIUNG INTL RCKH 46740 22 34N 120 20E 9 X T 6 TW

TAINAN TW-AFB RCNN 46743 22 56N 120 12E 19 X 7 TW

KANGSHAN TW-AFB RCAY 46745 22 46N 120 16E 10 X 7 TW

CHIAYI TW-AFB RCKU 46746 23 28N 120 22E 25 X 7 TW

DONGGANG RCMJ 46747 22 28N 120 25E 8 X 7 TW

PINGTUNG SOUTH RCDC 46750 22 40N 120 28E 24 X 7 TW

TAICHUNG TW-AFB RCLG 46751 24 10N 120 39E 112 X 7 TW

HENGCHUN RCKW 46752 21 55N 120 49E 13 X T 7 TW

HSINCHU TW-AFB RCPO 46756 24 49N 120 55E 8 X 7 TW

PINGTUNG N AFB RCSQ 46758 22 41N 120 28E 29 X 7 TW

CHIHHANG TW-AFB RCQS 46760 22 48N 121 10E 37 X 7 TW

LAN YU RCLY 46762 22 01N 121 32E 325 X T 6 TW

HUALIEN AB RCYU 46763 24 01N 121 37E 16 X 7 TW

ILAN RCMS 46764 24 45N 121 46E 9 X 7 TW

WUCHIA OBSERVATO RCMQ 46770 24 16N 120 37E 5 X 7 TW

CHIA TUNG RCFS 46772 22 25N 120 32E 20 X 7 TW

DONGSHA/PRATAS RCLM 46810 20 40N 116 43E 6 X 7 TW

以下是我的 template 檔,和 .conkyrc 的寫法很接近,只是多了一些新的變數:

${voffset 10}${font DroidSans:bold:size=14}天氣  ${font}${alignc}[SN]  [LU]  ${hr 2}${font}
${voffset 15}${goto 35}${font ConkyWeather:size=64}[PIF]${font}
${voffset -70}${goto 120}${font DejaVu Sans Mono:style=Bold:size=20}[PT]${font}
${goto 120}[CT]
${goto 120}Feels like: [FL]
${goto 120}${color3}UV: [UV] - [UVT]
${voffset 5}${goto 25}[D2D]${goto 75}[D3D]${goto 125}[D4D]${goto 175}[D5D]
${voffset 1}${goto 25}${font ConkyWeather:size=30}[D2F]${goto 75}[D3F]${goto 120}[D4F]${goto 175}[D5F]${font}
${voffset 3}${goto 25}[D2T]${goto 75}[D3T]${goto 125}[D4T]${goto 175}[D5T]${font}
${voffset 3}${goto 35}[D2P]${goto 85}[D3P]${goto 135}[D4P]${goto 185}[D5P]${font}${color}

上面的 [SN]、[LU]、[PT] 等等,就要看這個說明

以下是我的 .conkyrc 檔:

# .conkyrc by fabsh <fabsh@lamerk.org>
# Based on ideas and code from the CunchBang Linux forums at http://crunchbanglinux.org
# v. 1.0

# Use Xft?
use_xft yes
xftfont DroidSans:size=12
#xftfont DejaVu Sans:size=12
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

own_window yes
#own_window_transparent yes
#own_window_type override
#own_window_type desktop
#own_window_type normal #use this if you want a nice shadow to appear around conky

# If own_window is yes, these window manager hints may be used #設置conky為沒有邊框等等。
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

##################################
# 半透明
# yaourt -S compton-git
##################################
#own_window_class Conky
own_window yes
#設置conky的窗口屬性 desktop/NORMAL
own_window_type normal      #use this if you want a nice shadow to appear around conky
#設置conky的默認背景色
own_window_colour 222222
#很重要,只有啟用argb才能透明,但是如果窗口屬性如果設置為override,可能無法生效
own_window_argb_visual yes
#設置透明的alpha值0-255,0為透明,255不透明
own_window_argb_value 10
#如果啟用own_window_transparent,窗口完全透明,alpha值不起作用
own_window_transparent no   #yes
##################################

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
#minimum_size 180 0     # 重啟才有效
maximum_width 200

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_margin 5

# border width
border_width 0

# Default colors and also border colors
default_color white
#default_shade_color black
#default_outline_color grey
#own_window_colour grey
#color red,green,yellow,blue,magenta,cyan,black,white.
color1 FA9E10

# 相對於螢幕,Text alignment, other possible values are commented
alignment top_right
#alignment top_left
#alignment top_middle
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
border_inner_margin 15
gap_x 30
gap_y 30

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 1

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none

short_units yes

#########################
# 天氣: conkywx 要用的設定檔
#########################
template0 "/usr/bin/conkywx"
template1 "/home/mario/.config/conkywx/conkywx.conf"
template2 "/home/mario/.config/conkywx/wx-wu-font-slim-template.sh"

TEXT
###################################
# SYSTEM
###################################
${font DroidSans:bold:size=16}${color1}SYSTEM ${hr 2}${font}${color}
#${alignc 24}${font Arial Black:size=14}${nodename}${font}
#${alignc -8}HP Pavilion dv2500nr
#${voffset 2}${font Arial Black:style=Bold:size=12}#!${font} CrunchBang Linux ${alignr}08.10.01
${font OpenLogos:size=14}u${font} Kernel: ${alignr}${kernel}
${font StyleBats:size=14}q${font} Uptime: ${alignr}${uptime}
#${font StyleBats:size=14}A${font} CPU : ${font} ${alignr}${cpubar cpu0 8,60}

${font DroidSans:bold:size=16}CPU: ${font}${hwmon 0 temp 1}°C $alignr${freq_g 1}GHz   ${cpugraph cpu0 8,60}
${font StyleBats:size=14}A${font} CPU1: ${cpu cpu1}% ${alignr}${cpubar cpu1 8,80}
${font StyleBats:size=14}A${font} CPU2: ${cpu cpu2}% ${alignr}${cpubar cpu2 8,80}
${font StyleBats:size=14}A${font} CPU3: ${cpu cpu3}% ${alignr}${cpubar cpu3 8,80}
${font StyleBats:size=14}A${font} CPU4: ${cpu cpu4}% ${alignr}${cpubar cpu4 8,80}
${font StyleBats:size=14}g${font} RAM: $mem/$memmax ${alignr}$memperc% ${membar 8,40}
${font StyleBats:size=14}j${font} SWAP: $swapperc% ${alignr}${swapbar 8,80}

${font DroidSans:bold:size=14}NAME          ${goto 100}CPU%            ${goto 150}${alignr}MEM%${font}
${top name 1} ${goto 100}${top cpu 1}    ${goto 160}${alignr}${top mem 1}
${top name 2} ${goto 100}${top cpu 2}    ${goto 160}${alignr}${top mem 2}
${top name 3} ${goto 100}${top cpu 3}    ${goto 160}${alignr}${top mem 3}
${top name 4} ${goto 100}${top cpu 4}    ${goto 160}${alignr}${top mem 4}
${top name 5} ${goto 100}${top cpu 5}    ${goto 160}${alignr}${top mem 5}
#${font Webdings:size=14}~${font} Battery: ${battery_percent BAT0}% ${alignr}${battery_bar 8,60 BAT0}

##################################
# DATE
##################################
${font DroidSans:bold:size=16}${color1}DATE ${hr 2}${font}${color}
${voffset 3}${font DroidSans:size=18}${alignc}${time %A, %d %B %Y}${font}
${voffset 10}${font DroidSans:bold:size=24}${alignc}${time %H:%M}${font}
##################################
#WEATHER ${hr 2}
##################################
${execpi 7200 ${template0} -c ${template1} -t ${template2}}

##################################
# HD
##################################
${voffset -4}${font DroidSans:bold:size=16}${color1}HD ${hr 2}${font}${color}
${voffset 4}${font Pie charts for maps:size=14}7${font}Root: ${alignr}${fs_used /}/${fs_size /}   ${fs_bar 8,60 /}

##################################
# NETWORK
##################################
${font DroidSans:bold:size=16}${color1}NETWORK ${font}${alignr}${addrs ppp0}${color}
${voffset 0}${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed eth0}${alignr}${upspeedgraph eth0 8,60 black black}
${voffset 4}${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed eth0}${alignr}${downspeedgraph eth0 8,60 black black}
${voffset 4}${font PizzaDude Bullets:size=14}N${font} Upload: ${alignr}${totalup eth0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font} Download: ${alignr}${totaldown eth0}
##################################
# MPD
##################################
${if_mpd_playing}
${font DroidSans:bold:size=16}${color1}MPD${font} ${alignr}${mpd_vol}  ${mpd_bar 2,100}  ${mpd_length}${color}
${voffset 4}${mpd_album}
${voffset 4}${mpd_artist}
${voffset 4}${mpd_title}
${endif}

顏色有 red,green,yellow,blue,magenta,cyan,black,white。

也可以設定數值,如下

# 夢幻的橘色
color1 FA9E10