aboutsummaryrefslogtreecommitdiff
path: root/uleft
blob: 0efe9721f1fc22ebbb664e94a3c33d8f9011f2dd (plain)
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
#!/bin/sh

# uleft, uright, ukill, ufull, unext - start & kill urxvt with
# preferred geometry. the terminals persist when their shells exit
# (they just start a new one).

# any arguments passed to this script are passed thru to urxvt.

GLEFT="96x53+0+0"
GRIGHT="88x53+968+0"
GFULL="185x53+0+0"

murder_shell() {
	# kill the shell that called the shell that's running this script
	kill $( ps -o ppid --no-headers $( ps -o ppid --no-headers $$ ) )
	exit 0
}

get_next_geom() {
	# lets this script alternate between starting left and right terminals
	if [ ! -e ~/.uleftright ] || grep -q right ~/.uleftright; then
		G=$GLEFT
		echo left > ~/.uleftright
	else
		G=$GRIGHT
		echo right > ~/.uleftright
	fi

	echo "$G"
}

case "$0" in
	*kill*) murder_shell         ;;
	*left*) G=$GLEFT             ;;
	*full*) G=$GFULL             ;;
	*next*) G=$( get_next_geom ) ;;
	*)      G=$GRIGHT            ;;
esac

urxvt -g "$G" "$@" -e sh -c "while true; do bash -login; done" &>/dev/null &
disown