blob: 7436da3c319d48cbbd05daf2389d7dfac120138c (
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
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
|
#!/bin/sh
#
# Copyright (c) 2019 Aaron LI
# MIT License
#
# Default font and size
fontname=NotoSansMono-Regular
fontsize=11
usage() {
echo "usage: ${0##*/} [-f [fontname][:fontsize]] [acme_args ...]" >&2
echo "defaults: fontname: '${fontname}', fontsize: ${fontsize}" >&2
exit 1
}
is_running() {
pgrep -x -u "${USER}" "$1" >/dev/null 2>&1
}
get_font() {
local name size
case $1 in
*:*)
name="${1%:*}"
size="${1#*:}"
;;
*)
name="$1"
;;
esac
name="${name:-$2}"
size="${size:-$3}"
echo "/mnt/font/${name}/${size}a/font"
}
[ -n "${PLAN9}" ] || {
echo "ERROR: Environment variable 'PLAN9' not set!" >&2
exit 2
}
while getopts :f:h opt; do
case ${opt} in
f)
font="${OPTARG}"
;;
h)
usage
;;
\?)
echo "Invalid option -${OPTARG}" >&2
usage
;;
:)
echo "Option -${OPTARG} requires an argument" >&2
usage
;;
esac
done
shift $((${OPTIND} - 1))
FONT=$(get_font "${font}" ${fontname} ${fontsize})
is_running fontsrv || fontsrv &
is_running plumber || plumber
export TERM=dumb
export SHELL="${PLAN9}/bin/rc"
export PAGER="${PLAN9}/bin/nobs"
exec ${PLAN9}/bin/acme -a -f "${FONT}" "$@"
|