-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaterms
executable file
·355 lines (285 loc) · 9.76 KB
/
aterms
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/bin/bash
# shellcheck disable=SC2125,SC2017
# {{{
winder=/home/jaroslav/.local/bin/winder
small_fn='xft:Terminus:size=12'
small_fb='xft:UbuntuMono:size=12'
f_small="-fb $small_fb -fn $small_fn"
fn=-xos4-terminus-*-r-*-12-*
fb=-xos4-terminus-*-r-*-12-*
fn=-*-proggyclean-*-*-*-*-13-*-*-*-*-*-*-*
fb=-*-proggyclean-medium-*-*-*-13-*-*-*-*-*-*-*
proggy13=" -fb $fn -fn $fb "
fterminus14=-*-terminus-*-*-*-*-14-*-*-*-*-*-*-*
fnru=-xos4-*-*-r-*-*-14-*-*-*-*-*-*-r
fbru=-xos4-*-*-r-*-*-14-*-*-*-*-*-*-r
fnBIG=-misc-*-*-*-*-*-15-*-*-*-*-*-*-*
fbBIG=-misc-*-*-*-*-*-15-*-*-*-*-*-*-*
fnBIG=-misc-*-*-*-*-*-15-*-*-*-*-*-*-1
fbBIG=-misc-*-*-*-*-*-15-*-*-*-*-*-*-1
fnBIG=-*-terminus-*-*-*-*-14-*-*-*-*-*-*-1
fbBIG=-*-terminus-*-*-*-*-14-*-*-*-*-*-*-1
fnmpc=-xos4-*-*-r-*-*-14-*-*-*-*-*-*-*
fbmpc=-xos4-*-bold-r-*-*-14-*-*-*-*-*-*-*
#fn_t14=-xos4-terminus-*-*-*-14-*
#fb_t14=-xos4-terminus-*-*-*-14-*
fn_t14=xft:xos4\ Terminus:size=12
fb_t14=xft:xos4\ Terminus:style=bold
fn_t16=xft:xos4\ Terminus:size=16
fb_t16=xft:xos4\ Terminus:size=16:style=bold
terminus14="-fn $fn_t14 -fb $fb_t14"
fb=$fn
color="-fg 7 "
argsu="-ls -tr -sh 25 -fb $fb -fn $fn -w 0 -b 3 +sb" # Urxvt
argsa=" -ls -tr -sh 5 -fb $fb -fn $fn -bw 0 -ib 3 +sb"
argsb="$color -ls -tr -sh 5 -fb $fb -fn $fn -bw 0 -ib 5 -sb -trsb -sr"
argsa_big="-ls -tr -sh 5 -fb $fbBIG -fn $fnBIG -bw 0 -ib 3 +sb"
argsfu="-ls -tr -sh 12 -w 0 -b 3 +sb" # Urxvt
argsfu_big="-ls -tr -sh 25 -fb $fbBIG -fn $fnBIG -w 0 -b 3 +sb" # Urxvt
argsr="-ls -tr -sh 5 -fb $fn -fn -xos4-*-*-*-*-*-17-*-*-*-*-*-*-* +sb"
argsr="-ls -tr -sh 5 -fb $fbru -fn $fnru +sb"
argsn="-ls -tr -sh 5 -fb $fbmpc -fn $fnmpc +sb"
g='-geometry'
#su='sudo su -'
#su='sudo su -' g='-geometry'
l='-sl 36000' #s='-sl 100'
long='-sl 36000'
notab='-pe -tabbedex'
# }}}
##function get_res { xrandr | awk '/\*/ { print $1 }'; }
function one { urxvt -ls $argsu & }
function _wmctrl_desktop {
wmctrl -d | awk -v n=${1:-1} '$1==n { print }'
wmctrl -l -G -x | awk -v n=${1:-1} '$2==n { print }'
}
function get_res_total {
xrandr | awk '/\*/{gsub("x"," ",$0);w+=$1;h+=$2}END{print w "x" h}'
}
# assume primary monitor is in +0+0
function get_res { xrandr | grep -e '[0-9]\+x[0-9]\++0+0' -o | sed s/....$//; }
function get_width { xrandr | grep -e '[0-9]\+x[0-9]\++0+0' -o | sed s/x.*//; }
function get_height { xrandr | grep -e '[0-9]\+x[0-9]\++0+0' -o | sed -e 's/....$//; s/.*x//'; }
function _desktop_height_total { wmctrl -d | awk -v n=${1:-1} '$1==n { print $9}' | awk -Fx '{print $2}'; }
function _desktop_width_total { wmctrl -d | awk -v n=${1:-1} '$1==n { print $9}' | awk -Fx '{print $1}'; }
function _monitors { xrandr --listmonitors | awk 'NR==1 { print $2}'; }
function _count_desktop_wclass { _wmctrl_desktop ${1:-2} | grep ${2:-URxvt_d2} -c; }
function _kill_wclas { wmctrl -lpx | grep ${1:-URxvt_d3} | awk '{ print $3}' | xargs kill; }
function _anticipate_terms { #{{{
local desktop=$1
local filter_wclass=$2
local count=${3:-1}
for i in {1..20}; do
#set -x
if [[ `$winder -n -c $desktop $filter_wclass` -ge $count ]]; then
break
fi
#set +x
sleep 0.03
echo -n .
done # }}}
echo ,
}
function d2 {
#xrdb -merge ~/.Profile/Xdefaults/Xdefaults.urxvt
if [[ `_count_desktop_wclass 1 URxvt_d2` -lt 3 ]]; then
urxvt -name URxvt_d2 -ls $notab $long $g 120x30+10+10 &
urxvt -name URxvt_d2 -ls $notab $long $g 120x30-10+10 &
urxvt -name URxvt_d2 -ls $notab $long $g 120x30-10-10 &
else
echo we have 3 or more terms here
fi
_anticipate_terms 1 URxvt_d2 3
local w=$(get-res -w)
$winder 1 URxvt_d2 $(( -w / 100 * 5))
}
function d3 {
#xrdb -merge ~/.Profile/Xdefaults/Xdefaults.urxvt
if [[ `_count_desktop_wclass 2 URxvt_d3` -lt 3 ]]; then
urxvt -name URxvt_d3 $notab $long $g 120x30+10+10 &
urxvt -name URxvt_d3 $notab $long $g 120x30-10+10 &
urxvt -name URxvt_d3 $notab $long $g 120x30-10-10 &
else
echo we have 3 or more terms here
fi
_anticipate_terms 2 URxvt_d3 3
local w=$(get-res -w)
$winder 2 URxvt_d3 $(( w / 100 * 5))
}
function urxvt-error-log {
urxvt -sl 50000 -bw 2 -b 10 -geometry 200x60+20+0 -sb -fn 'xft:xos4 Terminus:size=12' -e ~/bin/tail-php
}
function s {
urxvt -name URxvt_hdmi -ls +sb $notab $long -fn 'Terminus 20' &
urxvt -name URxvt_hdmi -ls +sb $notab $long &
urxvt -name URxvt_hdmi -ls +sb $notab $long &
}
function koray { urxvt -fn xft:cure -fb xft:cure -letsp -3 ;}
function koray2 {
local f=xft:xos4\ terminus:size=8;
urxvt -fn "$f" -fb "$f:style=bold";
}
function big { urxvt $l $argsfu_big & }
function bigaterm { aterm $l $argsa_big & }
function flux { aterm -name one $l $argsa & }
function uni { urxvt -name one $l $argsu & }
function oneru { export LC_CTYPE=ru_RU.KOI8-R; aterm $l $argsr $g 90x38 & }
#function sone { echo aterm $l $argsb -fg $random_color $g 90x38 & }
function sone { aterm $l $argsb $g 90x38 & }
function logterm {
logtermfile="/home/jaroslav/tmp/syslog" # the file is a fifo which syslogng logs to
argslogterm="-name logterm -ls -tr -sh 5 -fb $fb -fn $fterminus14 -bw 0 -ib 3 -sb -trsb -sr -e cat $logtermfile"
aterm -geometry 128x67-88+13 $l $argslogterm &
}
function mpc { ncmpc; }
function ncmpc { aterm $l $argsn $g 100x74 -e ncmpc & }
# {{{
function fourFlux {
local font="-fn $fn_t16 -fb $fb_t16"
local name=-name\ URxvt_four
urxvt $name -fade 25 $l $argsfu $font $g 90x31+3+2 &
urxvt $name -fade 25 $l $argsfu $font $g 90x42+3-9 &
urxvt $name -fade 25 $l $argsfu $font $g 117x31-4+2 &
urxvt $name -fade 25 $l $argsfu $font $g 117x42-4-9 &
true;
}
# }}}
# {{{
function rsixFlux {
if [[ `get_res` = "1920x1080" ]]; then
true
sm1='91x12+3+2'
sm2='91x12+3+177'
sm3='91x15+3+352'
bg1='91x36+3-2'
bg2='147x40-3+2'
bg3='147x36-3-2'
#small_fb='xft:UbuntuMono:size=12'
small_fn='xft:Terminus:size=12'
small_fb='xft:Terminus:bold:size=12'
f_small="-fb $small_fb -fn $small_fn"
else
sm1='91X13+3+2'
sm2='91x12+3+177'
sm3='91x15+3+339'
bg1='91x37+3-20'
bg2='141x41-4+2'
bg3='141x37-4-19'
fi
sm=" +sb -name URxvt_rsix $f_small"
cmd='-e ssh root@localhost'
### # sm1='80x13+3+2'
### # sm2='80x12+3+177'
### # sm3='80x15+3+339'
### # bg1='80x36+3-3' # bot-left
### # bg2='128x35-4-3' # bot-right
### # bg3='138x39-4+2' # top-right
### # sm="-name URxvt_rsix"
### # cmd='-e ssh -Y root@localhost'
for res in $sm1 $sm2 $sm3 ;do
urxvt -fade 20 +sb $sm $l $g $res $proggy13 $cmd & sleep 0.1
done &
#urxvt -fade 20 +sb $sm $l $g 70x38+0+0 \
#-fb xft:Terminus:14 -fn xft:Terminus:14 $cmd & sleep 0.1
for res in $bg1 $bg2 $bg3 ;do
urxvt -fade 20 +sb $sm $l $g $res $terminus14 $cmd & sleep 0.2
done &
}
# }}}
function ishd {
xrandr | awk '
BEGIN { havehd=0 }
/\*/ { if ($1 == "1920x1080") { havehd=1 } }
END { exit havehd == 1 ? 0 : 1; }
'
}
base=$(basename $0)
if [[ -n $1 ]] && type $1 2>/dev/null | grep -q is.a.function; then
$1
elif type $base 2>/dev/null | grep -q is.a.function; then
$base # e.q ln ~/bin/aterms ~/bin/urxvt-error-log
else
(
echo Please give me one of the following function names as the first
echo argument to spawn a new terminal emulator:
echo
cat ${BASH_SOURCE[0]} | grep ^function | awk '{print $2}' | grep -v ^_
) | fmt -w 80
fi
function resize2 { # {{{
# <G>,<X>,<Y>,<W>,<H>
local desktop=$1
local filter_wclass=$2
local shift_from_middle=${3:-200}
local res=$(get_res)
local h=${res##*x} w=${res%%x*}
# echo W $w H $h F $filter_wclass D $desktop S $shift_from_middle
local horizontal=5 bmargin=6
# {{{
function width_left { echo $((w/2-shift_from_middle-4)); }
function width_right { echo $((w/2+shift_from_middle-horizontal-horizontal)); }
function x_middle { echo $((w/2-shift_from_middle+horizontal)); }
function y_middle { echo $((h/2+bmargin)); }
function height_full { echo $((h-bmargin)); }
function height_half { echo $((h/2-bmargin)); }
function height_half2 { echo $((h/2-bmargin-bmargin)); }
# }}}
function left_tall { wmctrl -i -r $1 -e 0,2,2,`width_left`,`height_full`; }
function right_top { wmctrl -i -r $1 -e 0,`x_middle`,2,`width_right`,`height_half`; }
function right_bot { wmctrl -i -r $1 -e 0,`x_middle`,`y_middle`,`width_right`,`height_half2`; }
# {{{
for i in {1..60}; do
if [[ `_wmctrl_desktop $desktop | grep $filter_wclass -c ` -gt 1 ]]; then
break
fi
sleep 0.03
echo -n .
done # }}}
# {{{
let c=0
for i in `_wmctrl_desktop $desktop | grep $filter_wclass | awk '{ print $1}'`;do
let c=c+1
echo $c $i
if (( c == 1)); then left_tall $i; fi
if (( c == 2)); then right_top $i; fi
if (( c == 3)); then right_bot $i; fi
done #}}}
} # }}}
function resize3 { #{{{
# <G>,<X>,<Y>,<W>,<H>
local desktop=$1
local filter_wclass=$2
local shift_from_middle=$3
local res=$(get_res)
local w=${res%%x*}
local h=${res##*x}
echo W $w H $h F $filter_wclass D $desktop S $shift_from_middle
local horizontal=5 bmargin=6
# {{{
function width_right { echo $((w/2-shift_from_middle-4)); }
function width_left { echo $((w/2+shift_from_middle-horizontal-horizontal)); }
function x_middle { echo $((w/2-shift_from_middle+horizontal)); }
function y_middle { echo $((h/2+bmargin)); }
function height_full { echo $((h-bmargin)); }
function height_half { echo $((h/2-bmargin)); }
function height_half2 { echo $((h/2-bmargin-bmargin)); }
# }}}
function right_tall { wmctrl -i -r $1 -e 0,`x_middle`,2,`width_left`,`height_full`; }
function left_top { wmctrl -i -r $1 -e 0,2,2,`width_right`,`height_half`; }
function left_bot { wmctrl -i -r $1 -e 0,2,`y_middle`,`width_right`,`height_half2`; }
# {{{
for i in {1..60}; do
if [[ `_wmctrl_desktop $desktop | grep $filter_wclass -c` -gt 1 ]]; then
break
fi
sleep 0.03
done # }}}
# {{{
let c=0
for i in `_wmctrl_desktop $desktop | grep $filter_wclass | awk '{ print $1}'`;do
let c=c+1
if (( c == 1)); then right_tall $i; fi
if (( c == 2)); then left_top $i; fi
if (( c == 3)); then left_bot $i; fi
done
} #}}}
# vim: foldmethod=marker