-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwilyterm
executable file
·40 lines (32 loc) · 1.16 KB
/
twilyterm
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
#!/bin/bash
#
# Author: Twily, Edited by Firescar96 2015
# Description: Spawn a new terminal window inside a drawn rectangle
# Requires: slop, uxterm
# Usage: Bind hotkey to $ sh ./drawterm
#
# Note: if using compton w/ shadows, exclude "class_g = 'slop'"
# Original of this file: http://pastebin.com/9sn8V0zZ
#
M=1 # slop border width
SCREENRES=$(xdpyinfo | grep 'dimensions:' | awk '{print $2}')
WIDTH=$(echo "$SCREENRES" | cut -d 'x' -f 1)
HEIGHT=$(echo "$SCREENRES" | cut -d 'x' -f 2)
COLS=211 #max width of terminal in columns #$(tput cols)
LINES=59 #max height of terminal in lines $(tput lines)
REC=$(slop -t 0 -b $M -c 1,1,1,1 -f "%w %h %x %y" --nokeyboard) || exit 1
IFS=' ' read -r W H X Y <<< "$REC"
if [ "$W" -gt "1" ]; then
echo "$W"
echo "$H"
# Calculate width and height to block/font size
dW="$(echo "scale=10; $W / $WIDTH * $COLS" | bc)"
dH="$(echo "scale=10; $H / $HEIGHT * $LINES" | bc)"
nW=$(printf "%.0f" $dW)
nH=$(printf "%.0f" $dH)
echo "$nW"
echo "$nH"
gnome-terminal --geometry="${nW}x${nH}+${X}+${Y}" &
fi
exit 0
)