-
Notifications
You must be signed in to change notification settings - Fork 0
/
xterms.conf.pl.sample
134 lines (119 loc) · 4.48 KB
/
xterms.conf.pl.sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use Data::Dumper;
{
my ($root_width, $root_height, $root_x, $root_y)
= `xwininfo -root`
=~ /-geometry ([0-9]+)x([0-9]+)([+-][0-9]+)([+-][0-9]+)/;
if ($root_width > 1920) {
$root_width = 1920;
}
my $xft_metric_regex = join("\n",
"XFTM_ASCENT=([0-9]+);",
"XFTM_DESCENT=([0-9]+);",
"XFTM_HEIGHT=([0-9]+);",
"XFTM_MAX_ADVANCE=([0-9]+);",
);
chomp(my $font_spec = `xrdb -query`);
print STDERR "Could not get font_spec from xrdb\n" if ! $font_spec;
my %xrdb;
foreach my $spec (split "\n", $font_spec) {
my ($class, $attr, $value) = split /[*.:]+/, $spec;
$value =~ s/^\s+//;
$value =~ s/\s+$//;
$xrdb{$class}{$attr} = $value;
}
#my ($faceName, $class, $faceSize)
# = $font_spec =~ /.*Term\*faceName:\s*([^\n]+)\n([A-Za-z]+)Term\*faceSize:\s*([^\n]+)\n/s;
#print STDERR "class [$class]\n";
#exit 1;
#print Dumper \%xrdb;
#exit 1;
my $faceName = $xrdb{UXTerm}{faceName};
my $faceSize = $xrdb{UXTerm}{faceSize};
print STDERR "Could not get faceName and/or faceSize for class UXterm\n"
if ! $faceName || ! $faceSize;
# = $font_spec =~ /.*Term\*faceName:\s*([^\n]+)\n([A-Za-z]+)Term\*faceSize:\s*([^\n]+)\n/s;
my $xft_metric = `xftmetric '$faceName' $faceSize`;
my ($XFTM_ASCENT, $XFTM_DESCENT, $XFTM_HEIGHT, $XFTM_MAX_ADVANCE)
= $xft_metric =~ /$xft_metric_regex/;
my $H = $XFTM_ASCENT + $XFTM_DESCENT;
my $W = $XFTM_MAX_ADVANCE;
# Border Size
my $bs = 1;
# Full Width
my $fw = int($root_width / $W);
my $hmargin = int($root_width % $W / 2);
# Full Height
my $fh = int($root_height / $H);
my $vmargin = int($root_height % $H / 2);
# Half height
my $hh = int($fh / 2);
my $lop = 0;
if ($hh * 2 < $fh) {
# vertically lopsided
$lop = 1;
}
# Half Width
my $hw = int($fw/2);
# Head room.
my $head = ($root_height % $H - $bs - $bs);
my $hr = 0;
if ($head > 0) {
$hr = '+' . $head;
}
# Comfort Width
my $cw = 84;
# Legroom
my $lr = 25;
my $left_x = -$bs + $hmargin;
my $second_half = $hw*$W + $hmargin;
my $geometries_1366_768 = {
hilite => join('', $fw, 'x', $hh+$lop , '+', $left_x, '+', $hr),
lolite => join('', $fw, 'x', $hh , '+', $left_x, '-', 0),
#kraken => join('', $hw, 'x', $fh , '+', $second_half, '+', $hr),
#mermaid=> join('', $hw, 'x', $fh , '+', $left_x, '+', $hr),
#-geometry 85x45+1920-0
kraken => join('', 85, 'x', 45 , '+', 1920, '-', 0),
mermaid => join('', 85, 'x', 45 , '+', (1920 + 85 * $W), '-', 0),
full => join('', $fw, 'x', $fh , '+', $left_x, '+', $hr),
gran => join('', $hw, 'x', $fh - $lr, '+', $left_x, '+', $hr),
imp => join('', $hw, 'x', $fh - $lr, '+', $second_half, '+', $hr),
rtfm => join('', $hw, 'x', $fh , '+', $second_half, '+', $hr),
shells => join('', $hw, 'x', $fh , '+', $left_x, '-', 0),
vims => join('', $hw, 'x', $fh , '+',
# Place it right next to shells
$second_half, '-', 0),
any => join('',
# Fill up remaining space after shells and vims
$hw, 'x', $fh, '+', $second_half, '+', $hr),
zoo => join('', $hw, 'x', $fh - $lr, '+', $left_x, '-', 0),
bee => join('', $hw, 'x', $fh - $lr, '+', $second_half, '-', 0),
};
my $geometries = {
hilite => join('', $fw - $cw, 'x', $hh+$lop , '-', -$bs, '+', $hr),
kraken => join('', int($fw/2), 'x', $fh , '-', -$bs, '+', $hr),
mermaid=> join('', int($fw/2), 'x', $fh , '+', -$bs, '+', $hr),
lolite => join('', $fw - $cw, 'x', $hh , '-', -$bs, '-', 0),
full => join('', $fw , 'x', $fh - $lr, '+', -$bs, '+', $hr),
gran => join('', $hw , 'x', $fh - $lr, '+', -$bs, '+', $hr),
imp => join('', $hw , 'x', $fh - $lr, '-', -$bs, '+', $hr),
rtfm => join('', $hw , 'x', $fh , '-', -$bs ,'+', $hr),
shells => join('', $cw , 'x', $fh , '+', -$bs, '-', 0),
vims => join('', $cw , 'x', $fh , '+',
# Place it right next to shells
$cw * $W, '-', 0),
any => join('',
# Fill up remaining space after shells and vims
$fw - $cw * 2, 'x', $fh, '-', -1, '+', $hr),
};
my %config = (
cellh => $H,
cellw => $W,
muxer => 'Tmux',
geometries => $geometries_1366_768,
);
if (__PACKAGE__ eq 'main') {
print "ohai\n";
print Dumper \%config;
}
%config;
}