updates. colors, urxvt, font-size script

This commit is contained in:
Frieder Schlesier 2016-05-30 18:00:06 +02:00
parent 142b1ebdf6
commit ec18df8be4
7 changed files with 583 additions and 3 deletions

1
.Xdefaults Symbolic link
View File

@ -0,0 +1 @@
.Xresources

143
.Xresources Normal file
View File

@ -0,0 +1,143 @@
!!URxvt.perl-ext-common: selection-to-clipboard, font-size
!!URxvt.background: black
!!URxvt.secondaryScroll: true
URxvt.font: xft:Bitstream Vera Sans Mono:pixelsize=12
URxvt.perl-ext-common: default,matcher,font-size
URxvt.keysym.C-Up: font-size:increase
URxvt.keysym.C-Down: font-size:decrease
URxvt.keysym.C-S-Up: font-size:incglobal
URxvt.keysym.C-S-Down: font-size:decglobal
!! drop in Solarized colorscheme for Xresources/Xdefaults
!!SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B RGB HSB
!!--------- ------- ---- ------- ----------- ---------- ----------- -----------
!!base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21
!!base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26
!!base01 #586e75 10/7 brgreen 240 #585858 45 -07 -07 88 110 117 194 25 46
!!base00 #657b83 11/7 bryellow 241 #626262 50 -07 -07 101 123 131 195 23 51
!!base0 #839496 12/6 brblue 244 #808080 60 -06 -03 131 148 150 186 13 59
!!base1 #93a1a1 14/4 brcyan 245 #8a8a8a 65 -05 -02 147 161 161 180 9 63
!!base2 #eee8d5 7/7 white 254 #e4e4e4 92 -00 10 238 232 213 44 11 93
!!base3 #fdf6e3 15/7 brwhite 230 #ffffd7 97 00 10 253 246 227 44 10 99
!!yellow #b58900 3/3 yellow 136 #af8700 60 10 65 181 137 0 45 100 71
!!orange #cb4b16 9/3 brred 166 #d75f00 50 50 55 203 75 22 18 89 80
!!red #dc322f 1/1 red 160 #d70000 50 65 45 220 50 47 1 79 86
!!magenta #d33682 5/5 magenta 125 #af005f 50 65 -05 211 54 130 331 74 83
!!violet #6c71c4 13/5 brmagenta 61 #5f5faf 50 15 -45 108 113 196 237 45 77
!!blue #268bd2 4/4 blue 33 #0087ff 55 -10 -45 38 139 210 205 82 82
!!cyan #2aa198 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63
!!green #859900 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60
#define S_base03 #002b36
#define S_base04 #00171d
#define S_base02 #073642
#define S_base01 #586e75
#define S_base00 #c1cacd
#define S_base0 #839496
#define S_base1 #93a1a1
#define S_base2 #eee8d5
#define S_base3 #fdf6e3
#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: S_base04
URxvt*background: [88]S_base04
*foreground: S_base00
*depth: 32
!!*fading: 40
!!*fadeColor: S_base03
*cursorColor: S_base1
*pointerColorBackground:S_base01
*pointerColorForeground:S_base1
!! black dark/light
*color0: S_base02
*color8: S_base03
!! red dark/light
*color1: S_red
*color9: S_orange
!! green dark/light
*color2: S_green
*color10: S_base01
!! yellow dark/light
*color3: S_yellow
*color11: S_base00
!! blue dark/light
*color4: S_blue
*color12: S_base0
!! magenta dark/light
*color5: S_magenta
*color13: S_violet
!! cyan dark/light
*color6: S_cyan
*color14: S_base1
!! white dark/light
*color7: S_base2
*color15: S_base3
*utf8: 1
*saveLines: 999999
!-- Xft settings -- !
!!Xft.dpi: 144
Xft.rgba: rgb
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
! -- Fonts -- !
!!URxvt.font:xft:Inconsolata:pixelsize=27,style=Medium, xft:Symbola:pixelsize=19,style=Regular
!!URxvt.boldFont:xft:Inconsolata:style=Bold,pixelsize=27, xft:Symbola:pixelsize=19,style=Regular
!!*faceSize: 10
*bellIsUrgent: true
!! scroll
!! do not scroll with output
URxvt*scrollTtyOutput: false
!! scroll in relation to buffer (with mouse scroll or Shift+Page Up)
URxvt*scrollWithBuffer: true
!! scroll back to the bottom on keypress
URxvt*scrollTtyKeypress: true
!! scrollback buffer
URxvt.secondaryScreen: 1
URxvt.secondaryScroll: 0
URxvt.secondaryWheel: 1
!! scrollbar
*scrollBar: false
!URxvt*termName: rxvt
!! copy paste
URxvt*clipboard.copycmd: xclip -i -selection clipboard
URxvt*clipboard.pastecmd: xclip -o -selection clipboard
!! clickable urls
!!URxvt.url-launcher: /usr/local/bin/browser-exec
URxvt.matcher.button: 1
URxvt.url-select.underline: true
!! get option over to work
URxvt.keysym.M-Left: \033[1;5D
URxvt.keysym.M-Right: \033[1;5C
URxvt.keysym.Control-Left: \033[1;5D
URxvt.keysym.Control-Right: \033[1;5C

View File

@ -79,7 +79,7 @@ unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
xterm*|rxvt*|urxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)

View File

@ -133,6 +133,7 @@ gimp() {
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-v $HOME/Pictures:/root/Pictures \
-v $HOME/Documents:/root/Documents \
--name gimp \
fschl/gimp
@ -199,6 +200,7 @@ libreoffice() {
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-v $HOME/Documents:/root/Documents \
-v $HOME/Pictures:/root/Pictures \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--name libreoffice \

View File

@ -29,7 +29,7 @@ floating_modifier $mod
hide_edge_borders both # none|vertical|horizontal|both
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
bindsym $mod+Return exec urxvt
# kill focused window
bindsym $mod+Shift+q kill

434
.urxvt/ext/font-size Executable file
View File

@ -0,0 +1,434 @@
#!/usr/bin/perl
#
# On-the-fly adjusting of the font size in urxvt
#
# Copyright (c) 2008 David O'Neill
# 2012 Noah K. Tilton <noahktilton@gmail.com>
# 2012-2013 Jan Larres <jan@majutsushi.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# URL: https://github.com/majutsushi/urxvt-font-size
#
# Based on:
# https://github.com/dave0/urxvt-font-size
# https://github.com/noah/urxvt-font
#
#:META:X_RESOURCE:%.step:interger:font size increase/decrease step
=head1 NAME
font-size - interactive font size setter
=head1 USAGE
Put the font-size script into $HOME/.urxvt/ext/ and add it to the list
of enabled perl-extensions in ~/.Xresources:
URxvt.perl-ext-common: ...,font-size
Add some keybindings:
URxvt.keysym.C-Up: font-size:increase
URxvt.keysym.C-Down: font-size:decrease
URxvt.keysym.C-S-Up: font-size:incglobal
URxvt.keysym.C-S-Down: font-size:decglobal
Note that for urxvt versions older than 9.21 the resources have to look like this:
URxvt.keysym.C-Up: perl:font-size:increase
URxvt.keysym.C-Down: perl:font-size:decrease
URxvt.keysym.C-S-Up: perl:font-size:incglobal
URxvt.keysym.C-S-Down: perl:font-size:decglobal
Supported functions:
=over 2
=item * increase/decrease:
increase or decrease the font size of the current terminal.
=item * incglobal/decglobal:
same as above and also adjust the X server values so all newly
started terminals will use the same fontsize.
=item * incsave/decsave:
same as incglobal/decglobal and also modify the ~/.Xresources
file so the changed font sizes will persist over a restart of
the X server or a reboot.
=back
You can also change the step size that the script will use to increase
the font size:
URxvt.font-size.step: 4
The default step size is 1. This means that with this setting a
size change sequence would be for example 8->12->16->20 instead of
8->9->10->11->12 etc. Please note that many X11 fonts are only
available in specific sizes, though, and odd sizes are often not
available, resulting in an effective step size of 2 instead of 1
in that case.
=cut
use strict;
use warnings;
my %escapecodes = (
"font" => 710,
"boldFont" => 711,
"italicFont" => 712,
"boldItalicFont" => 713
);
sub on_start
{
my ($self) = @_;
$self->{step} = $self->x_resource("%.step") || 1;
foreach my $type (qw(font boldFont italicFont boldItalicFont)) {
$self->{$type} = $self->x_resource($type) || "undef";
}
}
# Needed for backwards compatibility with < 9.21
sub on_user_command
{
my ($self, $cmd) = @_;
my $step = $self->{step};
if ($cmd eq "font-size:increase") {
fonts_change_size($self, $step, 0);
} elsif ($cmd eq "font-size:decrease") {
fonts_change_size($self, -$step, 0);
} elsif ($cmd eq "font-size:incglobal") {
fonts_change_size($self, $step, 1);
} elsif ($cmd eq "font-size:decglobal") {
fonts_change_size($self, -$step, 1);
} elsif ($cmd eq "font-size:incsave") {
fonts_change_size($self, $step, 2);
} elsif ($cmd eq "font-size:decsave") {
fonts_change_size($self, -$step, 2);
} elsif ($cmd eq "font-size:reset") {
fonts_reset($self);
}
}
sub on_action
{
my ($self, $action) = @_;
my $step = $self->{step};
if ($action eq "increase") {
fonts_change_size($self, $step, 0);
} elsif ($action eq "decrease") {
fonts_change_size($self, -$step, 0);
} elsif ($action eq "incglobal") {
fonts_change_size($self, $step, 1);
} elsif ($action eq "decglobal") {
fonts_change_size($self, -$step, 1);
} elsif ($action eq "incsave") {
fonts_change_size($self, $step, 2);
} elsif ($action eq "decsave") {
fonts_change_size($self, -$step, 2);
} elsif ($action eq "reset") {
fonts_reset($self);
}
}
sub fonts_change_size
{
my ($term, $change, $save) = @_;
my @newfonts = ();
my $curres = $term->resource('font');
if (!$curres) {
$term->scr_add_lines("\r\nWarning: No font configured, trying a default.\r\nPlease set a font with the 'URxvt.font' resource.");
$curres = "fixed";
}
my @curfonts = split(/\s*,\s*/, $curres);
my $basefont = shift(@curfonts);
my ($newbasefont, $newbasesize) = handle_font($term, $basefont, $change, 0);
push @newfonts, $newbasefont;
# Only adjust other fonts if base font changed
if ($newbasefont ne $basefont) {
foreach my $font (@curfonts) {
my ($newfont, $newsize) = handle_font($term, $font, $change, $newbasesize);
push @newfonts, $newfont;
}
my $newres = join(",", @newfonts);
font_apply_new($term, $newres, "font", $save);
handle_type($term, "boldFont", $change, $newbasesize, $save);
handle_type($term, "italicFont", $change, $newbasesize, $save);
handle_type($term, "boldItalicFont", $change, $newbasesize, $save);
}
if ($save > 1) {
# write the new values back to the file
my $xresources = readlink $ENV{"HOME"} . "/.Xresources";
system("xrdb -edit " . $xresources);
}
}
sub fonts_reset
{
my ($term) = @_;
foreach my $type (qw(font boldFont italicFont boldItalicFont)) {
my $initial = $term->{$type};
if ($initial ne "undef") {
font_apply_new($term, $initial, $type, 0);
}
}
}
sub handle_type
{
my ($term, $type, $change, $basesize, $save) = @_;
my $curres = $term->resource($type);
if (!$curres) {
return;
}
my @curfonts = split(/\s*,\s*/, $curres);
my @newfonts = ();
foreach my $font (@curfonts) {
my ($newfont, $newsize) = handle_font($term, $font, $change, $basesize);
push @newfonts, $newfont;
}
my $newres = join(",", @newfonts);
font_apply_new($term, $newres, $type, $save);
}
sub handle_font
{
my ($term, $font, $change, $basesize) = @_;
my $newfont;
my $newsize;
my $prefix = 0;
if ($font =~ /^\s*x:/) {
$font =~ s/^\s*x://;
$prefix = 1;
}
if ($font =~ /^\s*(\[.*\])?xft:/) {
($newfont, $newsize) = font_change_size_xft($term, $font, $change, $basesize);
} elsif ($font =~ /^\s*-/) {
($newfont, $newsize) = font_change_size_xlfd($term, $font, $change, $basesize);
} else {
# check whether the font is a valid alias and if yes resolve it to the
# actual font
my $lsfinfo = `xlsfonts -l $font 2>/dev/null`;
if ($lsfinfo eq "") {
# not a valid alias, ring the bell if it is the base font and just
# return the current font
if ($basesize == 0) {
$term->scr_bell;
}
return ($font, $basesize);
}
my $fontinfo = (split(/\n/, $lsfinfo))[-1];
my ($fontfull) = ($fontinfo =~ /\s+([-a-z0-9]+$)/);
($newfont, $newsize) = font_change_size_xlfd($term, $fontfull, $change, $basesize);
}
# $term->scr_add_lines("\r\nNew font is $newfont\n");
if ($prefix) {
$newfont = "x:$newfont";
}
return ($newfont, $newsize);
}
sub font_change_size_xft
{
my ($term, $fontstring, $change, $basesize) = @_;
my @pieces = split(/:/, $fontstring);
my @resized = ();
my $size = 0;
my $new_size = 0;
foreach my $piece (@pieces) {
if ($piece =~ /^(?:(?:pixel)?size=|[^=-]+-)(\d+(\.\d*)?)$/) {
$size = $1;
if ($basesize != 0) {
$new_size = $basesize;
} else {
$new_size = $size + $change
}
$piece =~ s/(=|-)$size/$1$new_size/;
}
push @resized, $piece;
}
my $resized_str = join(":", @resized);
# don't make fonts too small
if ($new_size >= 6) {
return ($resized_str, $new_size);
} else {
if ($basesize == 0) {
$term->scr_bell;
}
return ($fontstring, $size);
}
}
sub font_change_size_xlfd
{
my ($term, $fontstring, $change, $basesize) = @_;
#-xos4-terminus-medium-r-normal-*-12-*-*-*-*-*-*-1
my @fields = qw(foundry family weight slant setwidth style pixelSize pointSize Xresolution Yresolution spacing averageWidth registry encoding);
my %font;
$fontstring =~ s/^-//; # Strip leading - before split
@font{@fields} = split(/-/, $fontstring);
if ($font{pixelSize} eq '*') {
$term->scr_add_lines("\r\nWarning: Font size undefined, assuming 12.\r\nPlease set the 'URxvt.font' resource to a font with a concrete size.");
$font{pixelSize} = '12'
}
if ($font{registry} eq '*') {
$font{registry} ='iso8859';
}
# Blank out the size for the pattern
my %pattern = %font;
$pattern{foundry} = '*';
$pattern{setwidth} = '*';
$pattern{pixelSize} = '*';
$pattern{pointSize} = '*';
# if ($basesize != 0) {
# $pattern{Xresolution} = '*';
# $pattern{Yresolution} = '*';
# }
$pattern{averageWidth} = '*';
# make sure there are no empty fields
foreach my $field (@fields) {
$pattern{$field} = '*' unless defined($pattern{$field});
}
my $new_fontstring = '-' . join('-', @pattern{@fields});
my @possible;
# $term->scr_add_lines("\r\nPattern is $new_fontstring\n");
open(FOO, "xlsfonts -fn '$new_fontstring' | sort -u |") or die $!;
while (<FOO>) {
chomp;
s/^-//; # Strip leading '-' before split
my @fontdata = split(/-/, $_);
push @possible, [$fontdata[6], "-$_"];
# $term->scr_add_lines("\r\npossibly $fontdata[6] $_\n");
}
close(FOO);
if (!@possible) {
die "No possible fonts!";
}
if ($basesize != 0) {
# sort by font size, descending
@possible = sort {$b->[0] <=> $a->[0]} @possible;
# font is not the base font, so find the largest font that is at most
# as large as the base font. If the largest possible font is smaller
# than the base font bail and hope that a 0-size font can be found at
# the end of the function
if ($possible[0]->[0] > $basesize) {
foreach my $candidate (@possible) {
if ($candidate->[0] <= $basesize) {
return ($candidate->[1], $candidate->[0]);
}
}
}
} elsif ($change > 0) {
# sort by font size, ascending
@possible = sort {$a->[0] <=> $b->[0]} @possible;
foreach my $candidate (@possible) {
if ($candidate->[0] >= $font{pixelSize} + $change) {
return ($candidate->[1], $candidate->[0]);
}
}
} elsif ($change < 0) {
# sort by font size, descending
@possible = sort {$b->[0] <=> $a->[0]} @possible;
foreach my $candidate (@possible) {
if ($candidate->[0] <= $font{pixelSize} + $change && $candidate->[0] != 0) {
return ($candidate->[1], $candidate->[0]);
}
}
}
# no fitting font available, check whether a 0-size font can be used to
# fit the size of the base font
@possible = sort {$a->[0] <=> $b->[0]} @possible;
if ($basesize != 0 && $possible[0]->[0] == 0) {
return ($possible[0]->[1], $basesize);
} else {
# if there is absolutely no smaller/larger font that can be used
# return the current one, and beep if this is the base font
if ($basesize == 0) {
$term->scr_bell;
}
return ("-$fontstring", $font{pixelSize});
}
}
sub font_apply_new
{
my ($term, $newfont, $type, $save) = @_;
# $term->scr_add_lines("\r\nnew font is $newfont\n");
$term->cmd_parse("\033]" . $escapecodes{$type} . ";" . $newfont . "\033\\");
# load the xrdb db
# system("xrdb -load " . X_RESOURCES);
if ($save > 0) {
# merge the new values
open(XRDB_MERGE, "| xrdb -merge") || die "can't fork: $!";
local $SIG{PIPE} = sub { die "xrdb pipe broken" };
print XRDB_MERGE "URxvt." . $type . ": " . $newfont;
close(XRDB_MERGE) || die "bad xrdb: $! $?";
}
}

View File

@ -50,7 +50,6 @@ base_applications() {
mount \
net-tools \
pulseaudio \
rxvt-unicode-256color \
ssh \
sudo \
tar \
@ -74,6 +73,7 @@ install_i3() {
i3 \
i3lock \
i3status \
rxvt-unicode-256color \
scrot \
slim \
xorg \