最新消息:

conky

Linux admin 4094浏览 0评论

  conky是Linux/Unix环境下面的一个用于可视化地显示系统信息的小程序,它可以嵌入到桌面,实时地显示CPU、内存、磁盘、文件系统、网络、电源等的状况,还可以显示一些特定程序的状态,比如moc, audacious, mpd&mpc等音乐播放器,甚至可以调用外部命令并将命令的输出显示出来。下面是我的conky截图,

conky

conky screenshot
下面简单解释下各部分的信息。
最上面一行显示当前时间和日期,调用的是系统命令date,当然也可以使用conky提供的$time变量。
第二行显示英文单词及其释义,由一个自定义脚本从一个单词列表中随机读取,里面是我平时积累的生词。
接下来是系统信息,当前登录系统的用户、系统运行时间、处理器占用率及CPU温度、系统负载因子(Load Average),CPU占用及磁盘I/O状况图,系统内存及使用状况,电源状况(状态,电池充电/放电剩余时间).
然后分别是CPU和内存占用前三甲进程的相关信息。
最后是MPD(Music Player Daemon)的状态。 

我的conky更新频率为1Hz,生词更新频率0.2Hz. ^_^

在设置生词显示过程中,遇到一个小插曲。我的生词表以dot文件的方式放在$HOME下,随机读取生词的Shell脚本randword.sh放在$HOME下的.bin目录中,.bin目录在.bashrc中被附加到$PATH中。另外,conky在.config/openbox/autostart.sh脚本中启动,autostart.sh脚本在openbox启动时被执行。
问题出现了,每次登入openbox,conky确实会被启动,但却没有生词被显示,但时间和日期是正确显示的。就是说date命令被执行了,但randword.sh却可能没被执行。经过我的描述,可能你已经发现问题的诱因了,但我却被生生搞了一个小时(>_<).
我是这样找到原因的。生词不是没被显示嘛,于是我在bash中杀掉重启conky,生词就显示了。问题就出在$PATH环境变量的设置上面,$PATH在bashrc中设置,而bashrc只在交互性且非登录的bash启动时才被读取(see man bash)。所以,autostart.sh中执行conky命令时,$PATH并不是我们在bashrc设置中所期望的结果,randword.sh脚本也就无法找到,更无法被执行了。
找到了原因,解决办法也就有了:以绝对路径调用randword.sh。然而,更好的方法可能是在.bash_profile文件中source一下.bashrc,因为bash_profile在交互性的登录shell或者非交互性带有–login选项的shell启动时被读取,详情请man bash.

最后奉上我的.conkyrc, 关于这份配置文件,如果你要使用的话,要注意,我使用的是consolas字体,你的系统可能没有,请在相应位置调整。显示生词,你很可能也没有相关文件和脚本。电源信息,你可能需要调整BAT1为BAT0或者其他。

# Use Xft? To let conky display Chinese, use xft!
use_xft yes
# Xft font when Xft is enabled
#xftfont wenquanyi bitmap song:size=10
xftfont Consolas:size=9
# Text alpha when using Xft
xftalpha 0.6
# Print everything to stdout?
# out_to_console no
#mail_spool $MAIL
# Update interval in seconds
update_interval 1.0
# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0
# Create own window instead of using desktop (required in nautilus)
# Set “no” to let conky transparent upon desktop.
own_window yes
# If own_window is yes, you may use type normal, desktop or override
own_window_type desktop
# Use pseudo transparency with own_window?
own_window_transparent yes
# If own_window_transparent is set to no, you can set the background colour here
#own_window_colour hotpink
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Minimum size of text area
minimum_size 100 3
maximum_width 308
# Draw shades?
draw_shades no
# Draw outlines?
draw_outline no
# Draw borders around text
draw_borders no
# Draw borders around graphs
draw_graph_borders no
# Stippled borders?
stippled_borders 8
# border width
border_width 1
# Default colors and also border colors
default_color white
default_shade_color black
default_outline_color black
# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment none
# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 12
gap_y 12
# 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 2
# seemingly required for Chinese
override_utf8_locale yes
# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer none
# Allow each port monitor to track at most this many connections (if 0 or not set, default is 256)
#max_port_monitor_connections 256
# Maximum number of special things, e.g. fonts, offsets, aligns, etc.
#max_specials 512
# Maximum size of buffer for user text, i.e. below TEXT line.
#max_user_text 16384
# Timing interval for music player thread, e.g. mpd, audacious
#music_player_interval (update_interval is default)
# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument
# stuff after ‘TEXT’ will be formatted on screen

TEXT
${color yellow}${exec date +”%T %a, %b/%d/%Y”}$color
${color #ee0000}${font wenquanyi bitmap song:size=10}${execi 5 /home/dutor/.bin/randword.sh}$font$color

${color green}System Info$color
   Usr:${color #0077ff} ${user_names}$alignr${color}Uptime:${color #0077ff} $uptime$color
   CPU:${color #0077ff} $cpu% ${acpitemp}°C$alignr${color}Load:${color #0077ff} ${loadavg}
   ${color #000000}${cpugraph 00ff00 aa0000 -t}$color
   $alignc${color}CPU Status
   ${color #000000}${diskiograph 00ff00 aa0000 -t}$color
   $alignc${color}Disk Status
   Memory:${color #0077ff} $memperc% $mem/4GB$color
   Battery:${color #0077ff} ${battery BAT1} ${battery_time BAT1} $color
#Battery Life:${color #cc2222} $apm_battery_time – $apm_battery_life $color

${color green}CPU Top 3$color
   Process$alignr PID    CPU%   MEM%   MEM
   ${color #0077ff}${top name 1}$alignr${top pid 1} ${top cpu 1} ${top mem 1} ${top mem_res 1}
   ${top name 2}$alignr${top pid 2} ${top cpu 2} ${top mem 2} ${top mem_res 2}
   ${top name 3}$alignr${top pid 3} ${top cpu 3} ${top mem 3} ${top mem_res 3}

${color green}Memory Top 3$color
   Process$alignr PID    CPU%   MEM%   MEM
   ${color #0077ff}${top_mem name 1}$alignr${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1} ${top_mem mem_res 1}
   ${top_mem name 2}$alignr${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2} ${top_mem mem_res 2}
   ${top_mem name 3}$alignr${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3} ${top_mem mem_res 3}

${color green}Music Player Daemon$color
   Status:${color #0077ff} $mpd_status $alignr${color}Volume:${color #0077ff} $mpd_vol$color
   Artist:${color #0077ff} ${font wenquanyi bitmap song:size=10}$mpd_artist$color${font}
   Title:${color #0077ff} ${font wenquanyi bitmap song:size=10}$mpd_title$color${font}
   Process:${color #0077ff} $mpd_bar

转载请注明:爱开源 » conky

您必须 登录 才能发表评论!