Merge pull request #944 from aidanharris/st-font
Font detection for suckless terminal (st)
This commit is contained in:
commit
91f8ba7a1f
1 changed files with 26 additions and 0 deletions
26
neofetch
26
neofetch
|
@ -2188,6 +2188,32 @@ END
|
||||||
"${XDG_CONFIG_HOME}/sakura/sakura.conf")"
|
"${XDG_CONFIG_HOME}/sakura/sakura.conf")"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"st")
|
||||||
|
[[ -z "$parent" ]] && parent="$(get_ppid "$PPID")"
|
||||||
|
|
||||||
|
term_font="$(ps -o command= -p "$parent" | grep -F -- "-f")"
|
||||||
|
if [[ "$term_font" ]]; then
|
||||||
|
term_font="${term_font/*-f/}"
|
||||||
|
term_font="${term_font/ -*/}"
|
||||||
|
else
|
||||||
|
# On Linux we can get the exact path to the running binary through the procfs
|
||||||
|
# (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.
|
||||||
|
# Technically "Font Name" is a valid font. As it doesn't specify any font options
|
||||||
|
# though it is hard to match it correctly amongst the rest of the noise.
|
||||||
|
[[ -n "$binary" ]] && \
|
||||||
|
term_font="$(strings "$binary" | \
|
||||||
|
grep -F -m 1 -e "pixelsize=" -e "size=" -e "antialias=" -e "autohint=")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
term_font="${term_font/xft:}"
|
||||||
|
term_font="${term_font/:*}"
|
||||||
|
;;
|
||||||
|
|
||||||
"terminology")
|
"terminology")
|
||||||
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" |\
|
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" |\
|
||||||
awk '/^font\.name$/{print a}{a=$0}')"
|
awk '/^font\.name$/{print a}{a=$0}')"
|
||||||
|
|
Loading…
Reference in a new issue