aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xacme/a71
1 files changed, 71 insertions, 0 deletions
diff --git a/acme/a b/acme/a
new file mode 100755
index 0000000..4d51ab7
--- /dev/null
+++ b/acme/a
@@ -0,0 +1,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 PAGER=nobs
+export TERM=dumb
+export tabstop=8
+
+exec ${PLAN9}/bin/acme -a -f "${FONT}" "$@"