我的 conky 配置 (入门)

在我的 LXDE 环境下,每当点击“显示桌面”(最小化所有窗口)时,conky 都会消失,尝试了很多方法都无法解决。

只好取消 pcmanfm 的“管理桌面并显示文件图标”选项。这样虽然解决了上述问题,但代价是不能用桌面了。

$ sudo pacman -S feh    一个轻量级、强大的图像查看器,同时它也可以用来管理桌面壁纸,特别适合缺少这类特性的独立窗口管理器。

  feh --bg-center /PATH/TO/壁纸         把这一行添加到 ~/.config/lxsession/LXDE/autostart

想要用桌面的话就把 own_window_type 改成 normal ,不要用"iconify all windows" 。

my ~/.conkyrc :

background no
override_utf8_locale yes
font DejaVu Sans
:size=9
xftfont DejaVu Sans
:size=9
use_xft yes
xftalpha 
0.1

update_interval 
1.5
total_run_times 
0
own_window yes
#own_window_class Conky
own_window_type desktop
own_window_transparent no
own_window_hints undecorated
,below,sticky,skip_taskbar,skip_pager
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
minimum_size 
165 5
maximum_width 
225

alignment top_right
gap_x 
5
gap_y 
45
#no_buffers yes
cpu_avg_samples 2
uppercase no 
use_spacer none
out_to_console no


default_color moccasin
default_shade_color black
default_outline_color grey90



TEXT
${Font}${font Yahei Mono
:size=9}${exec ~/scripts/lunardate.py }
${font} ${
exec whoami} @ $nodename${color} on $machine   ${font OpenLogos:size=21}B 
${voffset 
-12}${color}${font Weather:size=21}${execi 3600 ~/scripts/weathers.sh}${font Yahei Mono:size=9}  ${voffset -6}今日:${execi 7200 ~/scripts/conkytq.sh}
${font Yahei Mono
:size=9}${execi 7200 ~/scripts/conditions.sh}
${voffset 
-2}${color}${font Martin Vogel's Symbols:size=11}U${font}${color slate grey} UpTime:$alignr${color }$uptime  
${color}${font StyleBats:size=10}Q${font}${color slate grey} Kernel:$alignr${color }$kernel  
${font StyleBats:size=10}j${font Yahei Mono:size=9} 电池:$alignr ${font}$battery  
${color}${font StyleBats:size=10}A${font}${color slate grey} CPU temperature:    $alignr${color}${acpitemp}℃   
${color}usage: $alignc Core0: ${cpu cpu1} % $alignr Core1: ${cpu cpu2} %  
${voffset 2}${color}${font StyleBats:size=10}M${font Yahei Mono:size=9} 进程:$alignr$processes个 ($running_processes 个活跃进程)  
${voffset -3}${color}${font Martin Vogel
's Symbols:size=10}h${font}${color slate grey} Highest CPU:$alignr -PID-    CPU%  
${color 
#ddaa00}${top name 1}$alignr${top pid 1}   ${top cpu 1}  
${color lightgrey}${top name 2}$alignr${top pid 2}   ${top cpu 2}  
${color lightgrey}${top name 
3}$alignr${top pid 3}   ${top cpu 3}  
${voffset 
-3}${color}${font Martin Vogel's Symbols:size=10}j${font}${color slate grey} Highest MEM:$alignr -PID-    MEM%  
${color #ddaa00}${top_mem name 1}$alignr${top_mem pid 1}   ${top_mem mem 1}  
${color lightgrey}${top_mem name 2}$alignr${top_mem pid 2}   ${top_mem mem 2}  
${color lightgrey}${top_mem name 3}$alignr${top_mem pid 3}   ${top_mem mem 3}  
${voffset -4}${stippled_hr}
${color slate grey}RAM:${color}   $memperc% used$alignr$mem/$memmax
${color slate grey}/: ${color}  ${fs_free_perc /}% free$alignr${color}${fs_free /}/${fs_size /}
${font DejaVu Sans:size=8}${color slate grey}windows: ${color}  ${fs_free_perc /mnt/windows}% free$alignr${color}${fs_free /mnt/windows}/${fs_size /mnt/windows}
${color slate grey}cache: ${color}  ${fs_free_perc /mnt/cache}% free$alignr${color}${fs_free /mnt/cache}/${fs_size /mnt/cache}
${color slate grey}DATA: ${color}  ${fs_free_perc /mnt/DATA}% free$alignr${color}${fs_free /mnt/DATA}/${fs_size /mnt/DATA}
${fs_bar 3,102 /}  ${fs_bar 3,102 /mnt/windows} 
${fs_bar 3,102 /mnt/cache}  ${fs_bar 3,102 /mnt/DATA}  
${font}${color slate grey}Disk Read: ${color #8844ee}${diskio_read /dev/sda} $alignr ${color slate grey} Write: ${color #22ccff}${diskio_write /dev/sda}
${color}${font PizzaDude Bullets:size=12}?${font} IP Address: $alignr${addr eth0}
${color}${font Yahei Mono:size=9}总计: ${font PizzaDude Bullets:size=10}M${font}  ${totalup eth0} ${alignr}${font PizzaDude Bullets:size=10}S${font}  ${totaldown eth0}   
${color slate grey}${font} Up: ${color #22ccff}${upspeed eth0}k/s ${alignr}${color slate grey}Down: ${color #8844ee}${downspeed eth0}k/s
${voffset -4}${color}${upspeedgraph eth0 30,100 000000 ffffff}$alignr${downspeedgraph eth0 30,100 000000 ffffff}
${voffset -12}${color}${font Martin Vogel
's Symbols:size=20}k${font}${color slate grey} ${voffset -8}E-Mail: 河蟹@gmail.com
${font Yahei Mono
:size=9}${color}$alignr  有 ${color #22ccff}${texeci 7200 perl ~/scripts/check_gmail.sh} ${color}封新邮件,来自: 
${voffset -4}${font DejaVu Sans:size=8}${execi 7200 ~/scripts/gmail.pl `~/scripts/check_gmail.sh`} 
${if_running mpd}${voffset 
-20}${stippled_hr}
${voffset 
-4}${font Yahei Mono:size=9}$mpd_artist $alignr (${mpd_album}) 
${font Yahei Mono
:size=9}$mpd_title
${font}${execi 
2 ~/scripts/mpd.awk} ${color #88aadd}${mpd_bar 4,150} ${color}${font} $mpd_percent % 
$alignc ${font}${execi 1 mpc | grep '#' | cut -10- | cut -"(" -f1} ${font Webdings:size=12}X${font}:${mpd_vol} % 
${font Yahei Mono
:size=8}码率:${font} ${mpd_bitrate}kbps${font Yahei Mono:size=8}  随机:$mpd_random  循环:$mpd_repeat $endif

 lunardate.py :

#!/usr/bin/python
#coding=utf-8
import locale, time, liblunar
locale.setlocale(locale.LC_ALL, "")
t=time.localtime()
l=liblunar.Date()
l.set_solar_date(t.tm_year,t.tm_mon,t.tm_mday,t.tm_hour)
format="农历:%(NIAN)年%(YUE)月%(RI)日  生肖:%(shengxiao)"
print l.strftime(format)

 liblunar 来自这里,支持python binding。AUR中也有。

weather.sh :

#!/bin/bash
URL=http://www.g.cn/search?q=tq+成都
weather=/tmp/pogoda.txt

w3m 
-dump $URL > $weather
end=`cat -$weather | grep "当前:" | cut -f1`
let 
end=end+10

head 
-$end $weather | tail -11 | cut -" " -f1- > $weather
# iconv -f gbk -t utf-8 $weather > $weather   # 转化为utf-8编码
cnd=$(cat $weather | grep "当前:" | cut -4-)

if echo "$cnd" | grep ---'多云'; then
   
echo 'c'
elif 
echo "$cnd" | grep ---''; then
   
echo 'B'
elif 
echo "$cnd" | grep ---''; then
   
echo 'e'
elif 
echo "$cnd" | grep ---'小雨|中雨'; then
   
echo 'g'
elif 
echo "$cnd" | grep ---'大雨'; then
   
echo 'h'
elif 
echo "$cnd" | grep ---'阵雨'; then
   
echo 'i'
elif 
echo "$cnd" | grep ---'中雪|大雪'; then
   
echo 'j'
elif 
echo "$cnd" | grep ---'小雪'; then
   
echo 'k'
fi

 

conkytq.sh :

#!/bin/bash
weather=/tmp/pogoda.txt
tq=$(sed -'4,4p' $weather)
wind=$(sed -'2,2p' $weather)
temp=$(sed -'5,5p' $weather)
echo $tq    
echo '           ' $wind '   ' $temp

conditions.sh :

#!/bin/bash
weather=/tmp/pogoda.txt
week1=$(sed -'6,6p' $weather)
tq1=$(sed -'7,7p' $weather)
temp1=$(sed -'8,8p' $weather)
week2=$(sed -'9,9p' $weather)
tq2=$(sed -'10,10p' $weather)
temp2=$(sed -'11,11p' $weather)
echo $week1 ' ' $tq1  $temp1
echo $week2 ' ' $tq2  $temp2

gmail.pl :

未读邮件发件人
#!/usr/bin/perl

# Put this in ~/.gmail/ and use "crontab -e" to add something like
#
 "* * * * * ~/.gmail/gmail.pl > /dev/null" to run it every minute.
#
 ${exec ~/.gmail/gmail.pl} shows your inbox in Conky.
#
 Note that this was intended to be used with Gmail or any other
#
 ssl-enabled pop3 server.

# beginning of configuration

# pop3 host
$pop_host = "pop.gmail.com";

# pop3 username (for Gmail, I didn't have to put @gmail.com at the end)
$pop_user = "wqnmlgb";

# pop3 password
$pop_pass = "asshole";

# ssl port number (995 is what Gmail uses)
$ssl_port = "995";

# ssl protocol
$ssl_prot = "tcp";

# number of emails to show 读取命令行第一个参数
$dis_numb = $ARGV[0];
# end of configuration

use Mail::POP3Client;
use IO::Socket::SSL;

  my 
$socket = IO::Socket::SSL->new( PeerAddr => $pop_host,
                                     PeerPort 
=> $ssl_port,
                                     Proto    
=> $ssl_prot);
  my 
$pop = Mail::POP3Client->new();
  
$pop->User($pop_user);
  
$pop->Pass($pop_pass);
  
$pop->Socket($socket);
  
$pop->Connect();

$msg_count = $pop->Count();

for ($i = $msg_count; $i >0 && $i >= $msg_count-($dis_numb-1); $i--) {
  
foreach ( $pop->Head( $i ) ) {
    
#/^(From|Subject):\s+/i and print $_, "\n";
    if ($_ =~ m/^From:/) {
      (
$from= ($_ =~ m#^From: .*<(.*)>#);
      $from = substr($from, 0, 30);
      
$out .= "$from\n";
    }
  }
  
#chop $out;
}
  print
"$out";

$pop->Close();

运行这个perl脚本之前需要 sudo cpan -i YAML Mail::POP3Client IO::Socket::SSL

check_gmail.sh :

#!/bin/bash

gmail_login="账号" 
gmail_password="密码"

dane="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

if [ -"$dane" ]; then
echo "Error"
else
echo "$dane"
fi

mpd.awk :

#!/bin/awk -f

BEGIN {
    MPD_CMD = "mpc"# mpd

    MPD_CMD | getline;
    MPD_CMD | getline;
        mpd_state = $1;
    
close(MPD_CMD);
    
    
if ( mpd_state == "[playing]" )
        
print " ▶ ";
    
else
        {
        
if ( mpd_state == "[paused]" )
            
print " ❚❚";
        
else
            {
                
print " ■ ";
            }

        }
    }

 


 

原文地址:https://www.cnblogs.com/shankun/p/my_conkyrc_and_usefull_scripts.html