]> git.rmz.io Git - dotfiles.git/blob - bin/colorscheme2palette
nvim: provide wrappers to lazy.core.util.{error,warn,info}
[dotfiles.git] / bin / colorscheme2palette
1 #! /usr/bin/perl -w
2
3 # Converts a kde Color-Scheme to a Palette
4
5 use strict;
6 use warnings;
7 use File::Basename;
8
9 @ARGV == 1 or die "I need exactly one argument, a path to a .colors file";
10
11 my $dir = `kde4-config --localprefix`;
12 chomp $dir;
13 $dir = $dir."share/config/colors";
14
15 my $file = $ARGV[0];
16 my $name = basename($file, ".colors");
17
18 open(FILE, $file) or die $!;
19
20 my @lines;
21 while (<FILE>) {
22 if (/(.*)=(\d{1,3}),(\d{1,3}),(\d{1,3})/) {
23 my $line = "$2 $3 $4\t$1\n";
24 push(@lines, $line);
25 }
26 }
27 close FILE;
28
29 @lines = sort(@lines); # doesn't work, sorts as string not number
30
31 open(OUT, '>', "$dir/$name") or die $!;
32
33 print OUT "KDE RGB Palette\n";
34 print OUT "#\n";
35
36 foreach (@lines) {
37 print OUT;
38 }
39 close OUT;