diff options
author | Urbain Vaes <urbain@vaes.uk> | 2015-08-08 20:08:42 +0200 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2015-08-08 20:08:42 +0200 |
commit | 8df9472e0cdbab0d12211c2bc77918e8f515c409 (patch) | |
tree | f420b705adfec42bb33191c44c8fe252fca0f785 /urxvt/ext/rotate-colors | |
parent | b8a9b07b741cddbf6e0476e70c94aa186d62b6ae (diff) |
Improve installation and organization
Diffstat (limited to 'urxvt/ext/rotate-colors')
-rw-r--r-- | urxvt/ext/rotate-colors | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/urxvt/ext/rotate-colors b/urxvt/ext/rotate-colors deleted file mode 100644 index 0016d6a..0000000 --- a/urxvt/ext/rotate-colors +++ /dev/null @@ -1,92 +0,0 @@ -#! /usr/bin/env perl -w -# Author: John Tyree -# Website: http://github.com/johntyree/urxvt-perls/blob/master/rotate-colors -# License: CCBYNC - -# Use keyboard shortcuts to load colors of the form *.colorN:XXXXXX from a file -# This gives us "on demand" theme switching. - -# Usage: put the following lines in your .Xdefaults/.Xresources: -# URxvt.perl-ext-common: ...,rotate-colors -# URxvt.rotate-colors.files: ~/.Xresources,~/light.txt,~/dark.txt -# URxvt.keysym.M-C-n: perl:rotate-colors:next -# URxvt.keysym.M-C-p: perl:rotate-colors:prev - -use strict; - - -sub on_start { - my ($self) = @_; - $self->{current_index} = -1; - my @arr = split(/,/, $self->x_resource('files') || ''); - $self->{color_files} = \@arr; - - () -} - -sub read_colors { - my $fn = shift; - open my $fin, $fn or print STDERR "Unable to open $fn for reading"; - my %colors; - - while (my $line = <$fin>) { - if ($line =~ /(\w+)\s*:\s*(#[0-9a-fA-F]+)/) { - $colors{$1} = $2; - } - } - - return %colors -} - -sub escape_seq { - my ($k, $v) = @_; - my $cmd = ""; - if ($k =~ /^color(\d+)$/) { - $cmd = "4;$1;$v"; - } elsif ($k =~ /^colorBD$/) { - $cmd = "5;0;$v"; - } elsif ($k =~ /^colorUL$/) { - $cmd = "5;1;$v"; - } elsif ($k =~ /^colorBL$/) { - $cmd = "5;2;$v"; - } elsif ($k =~ /^colorRV$/) { - $cmd = "5;3;$v"; - } elsif ($k =~ /^foreground$/) { - $cmd = "10;$v"; - } elsif ($k =~ /^background$/) { - $cmd = "11;$v"; - } elsif ($k =~ /^cursorColor$/) { - $cmd = "12;$v"; - } elsif ($k =~ /^pointerColor$/) { - $cmd = "13;$v"; - } - - return '\033]'.$cmd.'\007' -} - -sub build_cmd { - my $fn = shift; - my %colors = read_colors($fn); - print $fn."\n"; - my $s = join("", map {escape_seq($_, $colors{$_})} keys %colors); - - return $s -} - -sub on_user_command { - my ($self, $cmd) = @_; - my @fs = @{$self->{color_files}}; - my $len = @fs; - - if ($cmd eq "rotate-colors:next") { - my $idx = $self->{current_index}++; - my $fn = $fs[$idx % scalar(@fs)]; - $self->cmd_parse(build_cmd($fn)); - } elsif ($cmd eq "rotate-colors:prev") { - my $idx = $self->{current_index}--; - my $fn = $fs[$idx % scalar(@fs)]; - $self->cmd_parse(build_cmd($fn)); - } - - () -} |