LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1385|回复: 6

conky:监测gmail邮件和与nautilus冲突的解决

[复制链接]
发表于 2006-9-24 11:13:34 | 显示全部楼层 |阅读模式
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路径。我的改成这样了:
  1. # It seems at least Redhat installs OpenSSL in /usr ...
  2. $openssl_path = '/usr' if -x '/usr/local/bin/openssl' || -x '/usr/sbin/openssl';$openssl_path = '/opt/ssl' if -x '/opt/ssl/bin/openssl'
  3.     || -x '/opt/ssl/sbin/openssl';
  4. $openssl_path = '/usr/local' if -x '/usr/local/bin/openssl';
  5. $openssl_path = '/apps/openssl/std' if -x '/apps/openssl/std/bin/openssl';
  6. $openssl_path = shift if @ARGV && $ARGV[0] ne '--';
复制代码



安装IO-Socket-SSL
如果上面都顺利,这里也应该不会有问题了
/usr/local/bin/perl Makefile.PL
make
make test
make install
上面全都顺利装上了,也许还有问题,你可以./gmail.pl试下,是不是还有类似这样我错误:
  1. 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.
  2. BEGIN failed--compilation aborted at ./gmail.pl line 32.
复制代码
不用慌,那是因为你装的SSL.pm不在那些默认位置中,做个连接过去就行了。


建议:一切按照默认,可以省很多麻烦。万一碰到什么问题,再看看上面要求注意的地方,说不定对你有帮助




随便说下gnome下conky无法自动运行的问题,那是由于和nautilus 冲突了
解决办法:
gconf-editor(没有就装一个)
Apps/Nautilus/Preferences/show_desktop 选否,用gnome的朋友注意了哦




附上我的~/.conkyrc:
  1. # Conky sample configuration
  2. #
  3. # the list of variables has been removed from this file in favour
  4. # of keeping the documentation more maintainable.
  5. # Check http://conky.sf.net for an up-to-date-list.
  6. # set to yes if you want Conky to be forked in the background
  7. background yes
  8. # X font when Xft is disabled, you can pick one with program xfontsel
  9. #font 5x7
  10. #font 6x10
  11. #font 7x13
  12. #font 8x13
  13. #font 9x15
  14. #font *mintsmild.se*
  15. #font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
  16. # Use Xft?
  17. use_xft yes
  18. # Xft font when Xft is enabled
  19. xftfont Bitstream Vera Sans Mono:size=10
  20. # Text alpha when using Xft
  21. xftalpha 0.8
  22. # Print everything to stdout?
  23. # out_to_console no
  24. # MPD host/port
  25. # mpd_host localhost
  26. # mpd_port 6600
  27. # mpd_password tinker_bell
  28. # Print everything to console?
  29. # out_to_console no
  30. # mail spool
  31. mail_spool $MAIL
  32. # Update interval in seconds
  33. update_interval 5.0
  34. # This is the number of times Conky will update before quitting.
  35. # Set to zero to run forever.
  36. total_run_times 0
  37. # Create own window instead of using desktop (required in nautilus)
  38. own_window no
  39. # If own_window is yes, you may use type normal, desktop or override
  40. own_window_type normal
  41. # Use pseudo transparency with own_window?
  42. own_window_transparent yes
  43. # If own_window_transparent is set to no, you can set the background colour hereown_window_colour hotpink
  44. # If own_window is yes, these window manager hints may be used
  45. #own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
  46. # Use double buffering (reduces flicker, may not work for everyone)
  47. double_buffer yes
  48. # Minimum size of text area
  49. minimum_size 80 3
  50. # Draw shades?
  51. draw_shades yes
  52. # Draw outlines?
  53. draw_outline no
  54. # Draw borders around text
  55. draw_borders no
  56. # Draw borders around graphs
  57. #draw_graph_borders yes
  58. # Stippled borders?
  59. stippled_borders 8
  60. # border margins
  61. border_margin 4
  62. # border width
  63. border_width 1
  64. # Default colors and also border colors
  65. default_color white
  66. default_shade_color black
  67. default_outline_color black
  68. # Text alignment, other possible values are commented
  69. #alignment top_left
  70. alignment top_right
  71. #alignment bottom_left
  72. #alignment bottom_right
  73. #alignment none
  74. # Gap between borders of screen and text
  75. # same thing as passing -x at command line
  76. gap_x 12
  77. gap_y 30
  78. # Subtract file system buffers from used memory?
  79. no_buffers yes
  80. # set to yes if you want all text to be in uppercase
  81. uppercase no
  82. # number of cpu samples to average
  83. # set to 1 to disable averaging
  84. cpu_avg_samples 2
  85. # number of net samples to average
  86. # set to 1 to disable averaging
  87. net_avg_samples 2
  88. # Force UTF8? note that UTF8 support required XFT #让你在conky显示中文
  89. override_utf8_locale yes
  90. # Add spaces to keep things from moving about?  This only affects certain objects.
  91. use_spacer no
  92. #   mldonkey_hostname     Hostname for mldonkey stuff, defaults to localhost
  93. #   mldonkey_port         Mldonkey port, 4001 default
  94. #   mldonkey_login        Mldonkey login, default none
  95. #   mldonkey_password     Mldonkey password, default none
  96. # boinc (seti) dir
  97. # seti_dir /opt/seti
  98. # Allow for the creation of at least this number of port monitors (if 0 or not set, default is 16)
  99. #min_port_monitors 6
  100. # Allow each port monitor to track at least this many connections (if 0 or not set, default is 256)
  101. #min_port_monitor_connections 256
  102. # none, xmms, bmp, audacious, infopipe (default is none)
  103. #xmms_player none
  104. # variable is given either in format $variable or in ${variable}. Latter
  105. # allows characters right after the variable and must be used in network
  106. # stuff because of an argument
  107. # stuff after 'TEXT' will be formatted on screen
  108. TEXT
  109. ${color white}$alignc$sysname $kernel on $machine
  110. ${color white}$alignc${exec whoami} @ $nodename
  111. $color$stippled_hr
  112. ${color}Date: ${color white}${time %A,%d %B}
  113. ${color}Time: ${color white}${time %k:%M:%S}${alignr}${color}Uptime: ${color white}$uptime
  114. $color$stippled_hr
  115. ${color lightgrey}CPU Usage:${color #cc2222} $cpu% ${cpubar}
  116. ${color lightgrey}RAM Usage:${color #FB11FA} $memperc% ${membar}
  117. ${color lightgrey}Swap Usage:${color #F78F17} $swapperc% ${swapbar}
  118. $color$stippled_hr
  119. ${color lightgrey}Networking:
  120. Down:${color #8844ee} ${downspeed eth0} k/s${color lightgrey} ${offset 80}Up:${color #22ccff} ${upspeed eth0} k/s
  121. ${color #0000ff}${downspeedgraph eth0 32,150 ff0000 0000ff} ${color #22ccff}${upspeedgraph eth0 32,150 0000ff ff0000}
  122. ${color lightgrey}               File systems:
  123. / $color${fs_used /}/${fs_size /} ${fs_bar /}
  124. ${color #88aadd}MPD: ${alignc}$mpd_artist - $mpd_title
  125. ${color #88aadd}$mpd_bar
  126. ${color #88aadd}${alignc}$mpd_status
  127. ${color}Name              PID     CPU%   MEM%
  128. ${color #ddaa00} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
  129. ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
  130. ${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
  131. ${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
  132. ${color}Mem usage
  133. ${color #ddaa00} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
  134. ${color lightgrey} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
  135. ${color lightgrey} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
  136. $stippled_hr
  137. ${color gray}hunterwlf@gmail.com${color white}
  138. ${color red}${exec cat ~/.gmail/.gmail_top}
复制代码

贴图一张

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
发表于 2006-9-24 12:03:24 | 显示全部楼层
aptitude install libio-socket-ssl-perl libmail-pop3client-perl
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-24 12:55:23 | 显示全部楼层
Post by troll
aptitude install libio-socket-ssl-perl libmail-pop3client-perl

汗,早来这里问就好了,我一看官方的说明档推荐自己编译,就干上了

PS:非常荣幸能得到troll的指点
回复 支持 反对

使用道具 举报

发表于 2006-9-24 12:59:40 | 显示全部楼层
你这话让我非常地不好意思。 ops:
回复 支持 反对

使用道具 举报

发表于 2006-11-5 12:06:37 | 显示全部楼层
如何开机加载conky。
有~.xinitrc下加的话启动一闪就没了
export LC_CTYPE=zh_CN.utf8
export XMODIFIERS=@im=fcitx
export XIM=fcitx
exoprt XIM_PROGRAM=fcitx
fcitx &
conky
startxfce4


还有locale是zh_CN.utf8时终端乱码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-5 13:00:31 | 显示全部楼层
Post by uljling
如何开机加载conky。
有~.xinitrc下加的话启动一闪就没了
export LC_CTYPE=zh_CN.utf8
export XMODIFIERS=@im=fcitx
export XIM=fcitx
exoprt XIM_PROGRAM=fcitx
fcitx &
conky
startxfce4


还有locale是zh_CN.utf8时终端乱码

有可能是和你的窗口管理器冲突了

是所有中文都乱码,还是只有编辑这个文件时是乱码?
回复 支持 反对

使用道具 举报

发表于 2006-11-7 08:52:51 | 显示全部楼层
终端有些乱码,有些正常,其它,如OPENOFFIECE也正常,中文.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表