weechat-opal/scripts/coloconv.pl

46 lines
1.0 KiB
Perl
Raw Normal View History

2016-08-09 06:55:47 +00:00
#!/usr/bin/perl
=pod
Reads plugins.conf from stdin, writes new plugins.conf to stdout, and
writes commands to restore the rest of the config options to stderr
Suggested operation:
cd .weechat
./coloconv.pl < plugins.conf > plugins.conf.new 2> commands
diff plugins.conf plugins.conf.new # to make sure nothing got clobbered
Then in WeeChat:
/exec -o .weechat/commands
=cut
my %profs;
2016-08-09 07:02:57 +00:00
my $desc = 0;
2016-08-09 06:55:47 +00:00
while (<>) {
2016-08-09 07:02:57 +00:00
$desc and print, next;
2016-08-09 06:55:47 +00:00
$_ !~ /^python\.embellish\./ and print, next;
s/^python\.embellish/python.colo/;
$_ !~ /^python\.colo\..*(?:pre|suf)/ and print, next;
2016-08-09 07:02:57 +00:00
$_ eq '[desc]' and ($desc = 1), print, next;
2016-08-09 06:55:47 +00:00
my ($prof, $k, $v) = /^python\.colo\.(.*)(pre|suf) = "(.*)"$/;
$v =~ s/\x02/%b/g;
$v =~ s/\x03/%c/g;
$v =~ s/\x0f/%o/g;
$v =~ s/\x16/%r/g;
$v =~ s/\x1f/%u/g;
if ($k eq 'pre') {
$profs{$prof} = "%0$v%o%0 %s%o%0 ";
} elsif ($k eq 'suf') {
$profs{$prof} .= $v;
}
}
for my $prof (keys %profs) {
print STDERR "/reload\n";
2016-08-09 06:55:47 +00:00
print STDERR "/set plugins.var.python.colo.${prof}fmt $profs{$prof}\n";
}