From 79d255272d1f0a35fc36a337bc91c9e4e5854fac Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Fri, 4 Jun 2021 11:07:26 +0200 Subject: [PATCH] workaround rxvt-unicode bug --- src/config-print | 32 -------------------------------- src/config-reload | 31 +++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 42 deletions(-) delete mode 100644 src/config-print diff --git a/src/config-print b/src/config-print deleted file mode 100644 index e29d815..0000000 --- a/src/config-print +++ /dev/null @@ -1,32 +0,0 @@ -#! perl - -use v5.20; -use strict; -use warnings; -no warnings "experimental"; - -our @resources = ( - qw( - background foreground cursorColor - pointerColor pointerColor2 - highlight borderColor - font geometry - ), - map { "color$_" } 0..15 - ); - -sub on_start { - my %fallbacks = ( - borderColor => "background", - cursorColor => "foreground"); - - for (@resources) { - my $val = $TERM->x_resource($_); - my $default = $TERM->x_resource($fallbacks{$_}); - if (not $val and $default){ - $val = $default - } - say "$_: " . $val; - } - exit; -} diff --git a/src/config-reload b/src/config-reload index a1a292d..eaad643 100644 --- a/src/config-reload +++ b/src/config-reload @@ -17,16 +17,21 @@ my $libdir = dirname(__FILE__); our @terms = (); -sub reload_all { - my @lines = `urxvt --perl-lib $libdir -pe config-print 2>&1`; - my %resource; - for (@lines) { - $resource{$1} = $2 if (/(.*?): (.*)/); +sub get_xresources { + my @entries = `xrdb -query`; + my %resources; + for (@entries) { + $resources{$2} = $3 if /^(URxvt)?\*([^:]+):\t+(.*)/; } + $resources{borderColor} //= $resources{background}; + $resources{cursorColor} //= $resources{foreground}; + return %resources; +} + +sub build_command { + my %resources = @_; my $cmd = ""; - my $i = 0; -RESOURCE: - for (keys %resource) { + for (keys %resources) { my $key; given ($_) { $key = "4;$1" when (/color(\d+)/); @@ -39,16 +44,22 @@ RESOURCE: $key = 708 when "borderColor"; $key = 710 when "font"; when ("geometry") { - if (my ($col, $row) = $resource{$_} =~ /(\d+)x(\d+)/) { + if (my ($col, $row) = $resources{$_} =~ /(\d+)x(\d+)/) { $cmd .= "\e[8;${row};${col}t"; } next RESOURCE; } default { next RESOURCE } } - my $val = $resource{$_}; + my $val = $resources{$_}; $cmd .= "\e]$key;$val\a"; } + return $cmd; +} + +sub reload_all { + my %resources = get_xresources; + my $cmd = build_command(%resources); for (@terms) { $_->cmd_parse($cmd); }