conky显示颜色的诡异现象。

其它类软件,非上述版软件
回复
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

conky显示颜色的诡异现象。

#1

帖子 tusooa »

viewtopic.php?f=21&t=287082没问题,用mlinfo.perl再ansi2conky.perl就显示不了颜色了。

代码: 全选

tlcr: 0 庚寅年七月二十日 11:48:25 ~
● ds scripts-eexp/mlinfo.perl
#!/usr/bin/env perl
# vim : ft=perl

use 5.010;
use Getopt::Long;
GetOptions('nocol' => \$nocol, 's'=>\$short);
$shortlen=10;
open (STDERR, ">/dev/stdout");
use LWP::Simple;
$_ = get("http://localhost:4080/submit?q=vd");
die "Couldn't get it!" unless defined $_;
/<table.*\/table>/s;
use HTML::TableExtract;
$te = HTML::TableExtract->new(depth => 1, count => 1);
$te->parse($&);
foreach $ts ($te->tables) {
  foreach $row ($ts->rows) {
        next if ! @$row[5];
        if($short){@$row[5]=substr(@$row[5],0,$shortlen);}
        if(! $nocol){
            $_="\e[4;32;40m@$row[5]\t\e[4;31m@$row[8]%\t@$row[15]KB/s\e[0m";
        } else {
            #$_="@$row[5] \t@$row[8]%\t@$row[15]KB/s\n";
            $_="@$row[5]\t@$row[8]%\t@$row[15]KB/s";
        }
        s/\s*\t/\t/gs;
        say;
  }
}
close(STDERR);
tlcr: 0 庚寅年七月二十日 12:00:03 ~
● ds scripts-eexp/ansi2conky.perl
#!/usr/bin/env perl

%colors = (
    0 => 'black',
    1 => 'red',
    2 => 'green',
    3 => 'yellow',
    4 => 'blue',
    5 => 'magenta',
    6 => 'cyan',
    7 => 'white',
);
$_ = join "",<STDIN>;
$_ .= "\${color}";
s/\e\[0m/\${color}/g;
s/\e\[0[01]m//g;
s/\e\[[0-9;]*?3(\d)[0-9;]*?m/\${color $colors{$1}}/g;
s/\${color}\s*(?=\${)//g;
print;
tlcr: 0 庚寅年七月二十日 12:00:19 ~
● 
命令行底下可以正常显示,到conky里面就显示不了颜色了。

代码: 全选

tlcr: 0 庚寅年七月二十日 12:00:19 ~
● mlinfo.perl -s
slackware-      89.6%    48.7KB/s
tlcr: 0 庚寅年七月二十日 12:00:42 ~
● mlinfo.perl -s -n
slackware-      89.6%    48.7KB/s
tlcr: 0 庚寅年七月二十日 12:00:44 ~
● mlinfo.perl -s | ansi2conky.perl
${color green}slackware-        ${color red}89.6%        48.7KB/s${color}%                tlcr: 0 庚寅年七月二十日 12:00:48 ~
● 
rr-RSS.perl就没问题。

代码: 全选

tlcr: 0 庚寅年七月二十日 12:00:48 ~
● rr-RSS.perl
${color green}骨头的博客:${color yellow}
gentoo下的pppoe拨号
湿地博物馆
${color green}xiooli的博客:${color yellow}
诡异的 gtk 程序启动出错
迁移运行中的 Archlinux 系统至移动硬盘
tlcr: 0 庚寅年七月二十日 12:01:45 ~
● 
conkyrc:

代码: 全选

tlcr: 0 庚寅年七月二十日 12:02:44 ~
● sed -n '81,86p' < ~/.conkyrc-rss
TEXT
${color}RSS${stippled_hr}
${color yellow}${execpi 600 rr-RSS.perl} # | sed -re 's/.{29}/&\n/g'}

${color}MLDonkey 状态${stippled_hr}
${color red}${exec mlinfo.perl -s | ansi2conky.perl}
tlcr: 0 庚寅年七月二十日 12:03:00 ~
● 

代码: 全选

] ls -ld //
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: conky显示颜色的诡异现象。

#2

帖子 eexpress »

execp才正常啊。
lol
你直接用red blue这些啊。那颜色太刺眼的。
● 鸣学
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: conky显示颜色的诡异现象。

#3

帖子 tusooa »

果然阿。
tks.
额,吾倒是不觉得刺眼阿。

代码: 全选

] ls -ld //
回复