Skip to content

Commit

Permalink
rotatecolors: still not working, some impossible shit from 70s
Browse files Browse the repository at this point in the history
  • Loading branch information
kovetskiy committed Jul 13, 2020
1 parent 38a49b1 commit a7e8673
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 61 deletions.
4 changes: 3 additions & 1 deletion .Xresources
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ URxvt.keysym.Control-Down: \033[1;5B
URxvt.keysym.Control-Left: \033[1;5D
URxvt.keysym.Control-Right: \033[1;5C

URxvt.perl-ext-common: clipboard,default
URxvt.files: /home/operator/.Xresources.dark
URxvt.perl-ext-common: clipboard,default,rotate-colors

URxvt.keysym.C-Mod4-a: perl:rotate-colors:next
URxvt.keysym.Mod4-c: perl:clipboard:copy
URxvt.keysym.Mod4-v: perl:clipboard:paste
URxvt.clipboard.copycmd: clipboard-copy
Expand Down
38 changes: 19 additions & 19 deletions .Xresources.dark
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
URxvt*color0: #424242
URxvt*color1: #ba3b38
URxvt*color2: #5d865f
URxvt*color3: #a8814a
URxvt*color4: #88afd4
URxvt*color5: #cc5985
URxvt*color6: #376360
URxvt*color7: #d0cfca
URxvt*color8: #5d5d5d
URxvt*color9: #e9605f
URxvt*color10: #79ab87
URxvt*color11: #f7d58a
URxvt*color12: #98c6ef
URxvt*color13: #e499b2
URxvt*color14: #579e9a
URxvt*color15: #f4f2eb
URxvt*background: #000000
URxvt*foreground: #ffffff
URxvt*cursorColor: #ffffff
*color0: #424242
*color1: #ba3b38
*color2: #5d865f
*color3: #a8814a
*color4: #88afd4
*color5: #cc5985
*color6: #376360
*color7: #d0cfca
*color8: #5d5d5d
*color9: #e9605f
*color10: #79ab87
*color11: #f7d58a
*color12: #98c6ef
*color13: #e499b2
*color14: #579e9a
*color15: #f4f2eb
*background: #000000
*foreground: #ffffff
*cursorColor: #ffffff

rofi.color-normal: #1c1c1c, #d8d8d8, #1c1c1c, #af8700, #ffffff
rofi.color-active: #1c1c1c, #d8d8d8, #1c1c1c, #af8700, #ffffff
Expand Down
62 changes: 22 additions & 40 deletions .Xresources.light
Original file line number Diff line number Diff line change
@@ -1,59 +1,41 @@
#define S_base03 #002b36
#define S_base02 #073642
#define S_base01 #586e75
#define S_base00 #657b83
#define S_base0 #839496
#define S_base1 #93a1a1
#define S_base2 #eee8d5
#define S_base3 #fdf6e3

*background: S_base3
*foreground: S_base00
*fadeColor: S_base3
*cursorColor: S_base01
*pointerColorBackground:S_base1
*pointerColorForeground:S_base01

#define S_yellow #b58900
#define S_orange #cb4b16
#define S_red #dc322f
#define S_magenta #d33682
#define S_violet #6c71c4
#define S_blue #268bd2
#define S_cyan #2aa198
#define S_green #859900
*background: #fdf6e3
*foreground: #657b83
*fadeColor: #fdf6e3
*cursorColor: #586e75
*pointerColorBackground:#93a1a1
*pointerColorForeground:#586e75

!! black dark/light
*color0: S_base02
*color8: S_base03
*color0: #073642
*color8: #002b36

!! red dark/light
*color1: S_red
*color9: S_orange
*color1: #dc322f
*color9: #cb4b16

!! green dark/light
*color2: S_green
*color10: S_base01
*color2: #859900
*color10: #586e75

!! yellow dark/light
*color3: S_yellow
*color11: S_base00
*color3: #b58900
*color11: #657b83

!! blue dark/light
*color4: S_blue
*color12: S_base0
*color4: #268bd2
*color12: #839496

!! magenta dark/light
*color5: S_magenta
*color13: S_violet
*color5: #d33682
*color13: #6c71c4

!! cyan dark/light
*color6: S_cyan
*color14: S_base1
*color6: #2aa198
*color14: #93a1a1

!! white dark/light
*color7: S_base2
*color15: S_base3
*color7: #eee8d5
*color15: #fdf6e3

rofi.color-normal: #eeeeee, #444444, #eeeeee, #af8700, #ffffff
rofi.color-active: #eeeeee, #444444, #eeeeee, #af8700, #ffffff
Expand Down
104 changes: 104 additions & 0 deletions .urxvt/ext/perl/rotate-colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#! /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;

our @terms = ();

sub on_start {
my ($self) = @_;
$self->{current_index} = -1;
my @arr = split(/,/, $self->x_resource('files') || '');
$self->{color_files} = \@arr;

push @terms, $TERM;

()
}

sub read_colors {
my $fn = shift;
open my $fin, $fn or die "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 seq {
my ($self, $k, $v) = @_;
my $cmd = "";
my $n = "";
if ($k =~ /^color(\d+)$/) {
$n = $1;
$cmd = "4;$1;#ffffff";
#} 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";
} else {
print STDERR "unknown: " . $k . ":" . $v."\n";
return '';
}

$cmd = '\e]'.$cmd.'\007';

print STDERR $cmd . "\n";

$self->resource("color+".$n, $v);

$self->cmd_parse($cmd);
}

sub build_cmd {
my ($self, $fn) = @_;
my %colors = read_colors($fn);

map {$self->seq($_, $colors{$_})} keys %colors;
}

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->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));
}

()
}
1 change: 0 additions & 1 deletion vim.d/00-base.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ set winminheight=0
set clipboard=unnamedplus
set tags=./.tags;/
set cc=80,100
set termguicolors

set rtp-=~/.vim
set rtp^=~/.vim
Expand Down
1 change: 1 addition & 0 deletions vim.d/01-plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if $BACKGROUND == "dark"
endif

if $BACKGROUND == "light"
set termguicolors
Plug 'altercation/vim-colors-solarized'
Plug 'lifepillar/vim-solarized8'
func! _setup_colorscheme()
Expand Down

0 comments on commit a7e8673

Please sign in to comment.