|
conky是一个很不错的系统监测软件,资源占用少,还有不少“花样”可以玩,监测gmail邮件就是一个。我捣鼓了半天,总算搞定了。其实原理并不复杂,就是安装的时候有一些细节要注意,不然会让你抓狂的。要实现对gmail的邮件监测,只要一个perl脚本,再在conky中显示就可以了。
perl脚本在这里:http://conky.sourceforge.net/gmail.pl ,把它保存在~/.gmail下,并加上可执行权限。
脚本里有一处关键地方:
use Mail: OP3Client;
use IO::Socket::SSL;
这里必需装上Mail: OP3Client,和IO::Socket::SSL才能实现监测功能
Mail: OP3Client是一个面向对象的pop3服务器接入模块
IO::Socket::SSL是实现SSL信息加密传输的模块
Mail: OP3Client安装比较简单
cpan -i Mail: OP3Client 就能搞定了
IO::Socket::SSL我用类似方法装不上老是提示错误,于是我选择编译安装。它要求perl,openssl要用同样的编译器编译生成,而各发行版提供的如deb包、rpm包等,不知道是用什么来编译的,所以官方推荐自己编译perl和openssl,切记选定相同的编译器。
准备好需要的source:
http://www.cpan.org/src/stable.tar.gz
http://www.openssl.org/source/openssl-0.9.8c.tar.gz
http://cpan.uwinnipeg.ca/cpan/au ... ket-SSL-1.01.tar.gz
http://cpan.uwinnipeg.ca/cpan/au ... Leay.pm-1.30.tar.gz
安装perl
./Configure -de。这样使用了所有默认设置,包括默认的编译器是cc。如果你想用其它如gcc来编译,那么./Configure,有一步是让你先C编译器的,我选了gcc,其它默认就行了.这里要是用gcc的朋友要注意了,待会编译openssl时默认也是用cc的,如果你这里选用gcc,则openssl也要用gcc。
make
make test
make install
注意:这里的perl是装在/usr/local/bin下的,等会要用这个来运行Net::SSLeay的编译安装文件。
安装openssl
./config 。默认也是用cc编译的。这里有一点要注意,可能很多人为了方便软件包的管理喜欢加上 --prefix=/usr/local 参数,而它默认的的 安装位置是/usr/local/ssl,这将会给下面的安装带来麻烦,建议不要改安装路径。
make
make test
make install
安装Net::SSLeay(安装IO-Socket-SSL必需)
/usr/local/bin/perl Makefile.PL -t 。
make install
这里有两个地方要注意:
(一)我这里不能用./Makefile.PL来运行,虽然官方的说明里是这么写的。我系统里本来已经有perl了,但那个是用cc编译的,所以必须用我上面刚装的gcc编译的版本。
(二)Makefile.PL默认的openssl的安装路径是/usr/local/ssl,这也是我建议不要改openssl安装路径的原因。如果你上面改的openssl的路径,那么要修改Makefile.PL文件中的openssl路径。我的改成这样了:- # It seems at least Redhat installs OpenSSL in /usr ...
- $openssl_path = '/usr' if -x '/usr/local/bin/openssl' || -x '/usr/sbin/openssl';$openssl_path = '/opt/ssl' if -x '/opt/ssl/bin/openssl'
- || -x '/opt/ssl/sbin/openssl';
- $openssl_path = '/usr/local' if -x '/usr/local/bin/openssl';
- $openssl_path = '/apps/openssl/std' if -x '/apps/openssl/std/bin/openssl';
- $openssl_path = shift if @ARGV && $ARGV[0] ne '--';
复制代码
安装IO-Socket-SSL
如果上面都顺利,这里也应该不会有问题了
/usr/local/bin/perl Makefile.PL
make
make test
make install
上面全都顺利装上了,也许还有问题,你可以./gmail.pl试下,是不是还有类似这样我错误:- Can't locate IO/Socket/SSL.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at ./gmail.pl line 32.
- BEGIN failed--compilation aborted at ./gmail.pl line 32.
复制代码 不用慌,那是因为你装的SSL.pm不在那些默认位置中,做个连接过去就行了。
建议:一切按照默认,可以省很多麻烦。万一碰到什么问题,再看看上面要求注意的地方,说不定对你有帮助
随便说下gnome下conky无法自动运行的问题,那是由于和nautilus 冲突了
解决办法:
gconf-editor(没有就装一个)
Apps/Nautilus/Preferences/show_desktop 选否,用gnome的朋友注意了哦
附上我的~/.conkyrc:- # Conky sample configuration
- #
- # the list of variables has been removed from this file in favour
- # of keeping the documentation more maintainable.
- # Check http://conky.sf.net for an up-to-date-list.
- # set to yes if you want Conky to be forked in the background
- background yes
- # X font when Xft is disabled, you can pick one with program xfontsel
- #font 5x7
- #font 6x10
- #font 7x13
- #font 8x13
- #font 9x15
- #font *mintsmild.se*
- #font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
- # Use Xft?
- use_xft yes
- # Xft font when Xft is enabled
- xftfont Bitstream Vera Sans Mono:size=10
- # Text alpha when using Xft
- xftalpha 0.8
- # Print everything to stdout?
- # out_to_console no
- # MPD host/port
- # mpd_host localhost
- # mpd_port 6600
- # mpd_password tinker_bell
- # Print everything to console?
- # out_to_console no
- # mail spool
- mail_spool $MAIL
- # Update interval in seconds
- update_interval 5.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)
- own_window no
- # If own_window is yes, you may use type normal, desktop or override
- own_window_type normal
- # Use pseudo transparency with own_window?
- own_window_transparent yes
- # If own_window_transparent is set to no, you can set the background colour hereown_window_colour hotpink
- # If own_window is yes, these window manager hints may be used
- #own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
- # Use double buffering (reduces flicker, may not work for everyone)
- double_buffer yes
- # Minimum size of text area
- minimum_size 80 3
- # Draw shades?
- draw_shades yes
- # Draw outlines?
- draw_outline no
- # Draw borders around text
- draw_borders no
- # Draw borders around graphs
- #draw_graph_borders yes
- # Stippled borders?
- stippled_borders 8
- # border margins
- border_margin 4
- # 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 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 2
- # Force UTF8? note that UTF8 support required XFT #让你在conky显示中文
- override_utf8_locale yes
- # Add spaces to keep things from moving about? This only affects certain objects.
- use_spacer no
- # mldonkey_hostname Hostname for mldonkey stuff, defaults to localhost
- # mldonkey_port Mldonkey port, 4001 default
- # mldonkey_login Mldonkey login, default none
- # mldonkey_password Mldonkey password, default none
- # boinc (seti) dir
- # seti_dir /opt/seti
- # Allow for the creation of at least this number of port monitors (if 0 or not set, default is 16)
- #min_port_monitors 6
- # Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
- #min_port_monitor_connections 256
- # none, xmms, bmp, audacious, infopipe (default is none)
- #xmms_player none
- # 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 white}$alignc$sysname $kernel on $machine
- ${color white}$alignc${exec whoami} @ $nodename
- $color$stippled_hr
- ${color}Date: ${color white}${time %A,%d %B}
- ${color}Time: ${color white}${time %k:%M:%S}${alignr}${color}Uptime: ${color white}$uptime
- $color$stippled_hr
- ${color lightgrey}CPU Usage:${color #cc2222} $cpu% ${cpubar}
- ${color lightgrey}RAM Usage:${color #FB11FA} $memperc% ${membar}
- ${color lightgrey}Swap Usage:${color #F78F17} $swapperc% ${swapbar}
- $color$stippled_hr
- ${color lightgrey}Networking:
- Down:${color #8844ee} ${downspeed eth0} k/s${color lightgrey} ${offset 80}Up:${color #22ccff} ${upspeed eth0} k/s
- ${color #0000ff}${downspeedgraph eth0 32,150 ff0000 0000ff} ${color #22ccff}${upspeedgraph eth0 32,150 0000ff ff0000}
- ${color lightgrey} File systems:
- / $color${fs_used /}/${fs_size /} ${fs_bar /}
- ${color #88aadd}MPD: ${alignc}$mpd_artist - $mpd_title
- ${color #88aadd}$mpd_bar
- ${color #88aadd}${alignc}$mpd_status
- ${color}Name PID CPU% MEM%
- ${color #ddaa00} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
- ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
- ${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
- ${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
- ${color}Mem usage
- ${color #ddaa00} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
- ${color lightgrey} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
- ${color lightgrey} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
- $stippled_hr
- ${color gray}hunterwlf@gmail.com${color white}
- ${color red}${exec cat ~/.gmail/.gmail_top}
复制代码
贴图一张 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|