Refactor Code

This commit is contained in:
Aidan Harris 2018-04-10 02:55:08 +00:00
parent 9d4a127f72
commit 8fc70c9801
No known key found for this signature in database
GPG Key ID: E18BE27807DA2E96
1 changed files with 6 additions and 8 deletions

View File

@ -2179,17 +2179,15 @@ END
;;
"st")
if term_font="$(ps -o command= -p "$parent" | grep -E '\-f\s?.*?:?')"; then
term_font="$(ps -o command= -p "$parent" | grep -F -- "-f")"
if [[ "$term_font" ]]; then
term_font="${term_font/*-f/}"
term_font="${term_font/ -*/}"
else
binary=""
# On Linux we can get the exact path to the running binary through the procfs
# on other systems we just have to guess and assume `st` is invoked from somewhere
# in the users $PATH
[[ -L /proc/$parent/exe ]] && binary="/proc/$parent/exe"
[[ -z "$binary" ]] && binary="$(command -v st)"
# (in case `st` is launched from outside of $PATH) on other systems we just
# have to guess and assume `st` is invoked from somewhere in the users $PATH
[[ -L /proc/$parent/exe ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
# Grep the output of strings on the `st` binary for anything that looks vaguely
# like a font definition. NOTE: There is a slight limitation in this approach.
@ -2197,7 +2195,7 @@ END
# though it is hard to match it correctly amongst the rest of the noise.
[[ -n "$binary" ]] && \
term_font="$(strings "$binary" | \
grep -E '(pixelsize=|size=|antialias=|autohint=)' | head -1)"
grep -F -m 1 -e "pixelsize=" -e "size=" -e "antialias=" -e "autohint=")"
fi
term_font="${term_font/xft:}"