-
Notifications
You must be signed in to change notification settings - Fork 0
/
Z
executable file
·32 lines (26 loc) · 729 Bytes
/
Z
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
#!/bin/bash
# When called as Z-, this script zooms out. When called as Z+, it zooms in.
# Pass the font size delta as the second argument. If none is given, 1 is assumed.
set -eu
font=$(9p read acme/$winid/ctl | awk '{ print $7 }')
# Get current font size
cursz=$(echo "$font" | awk -F '/' '{ print $(NF - 1) }')
delta=${1:-1}
case "$(basename $0)" in
Z-)
incr=-$delta
;;
Z+)
incr=+$delta
;;
*)
echo wat
incr=+$delta
;;
esac
# Get new size
# Hack: This assumes antialiased fonts always
newsz=$(($(echo "$cursz" | tr -dc '[0-9]') + "$incr"))a
# New font
newfont=$(echo "$font" | awk -v newsz="$newsz" -F'/' '{ print "/mnt/font/"$4"/"newsz"/font" }')
printf "font %s\n" "$newfont" | 9p write acme/$winid/ctl