Merge pull request #252 from dylanaraps/term_font

Terminal and Terminal Font detection.
This commit is contained in:
Dylan Araps 2016-06-03 18:27:21 +10:00
commit e2e0811116
3 changed files with 93 additions and 5 deletions

View file

@ -3,7 +3,7 @@ ${c1} ,.=:!!t3Z3z.,
:tt:::tt333EE3 :tt:::tt333EE3
${c1} Et:::ztt33EEEL${c2} @Ee., .., ${c1} Et:::ztt33EEEL${c2} @Ee., ..,
${c1} ;tt:::tt333EE7${c2} ;EEEEEEttttt33# ${c1} ;tt:::tt333EE7${c2} ;EEEEEEttttt33#
${c1} :Et:::zt333EEQ.${c2} \$EEEEEttttt33QL ${c1} :Et:::zt333EEQ.${c2} $EEEEEttttt33QL
${c1} it::::tt333EEF${c2} @EEEEEEttttt33F ${c1} it::::tt333EEF${c2} @EEEEEEttttt33F
${c1} ;3=*^\`\`\`\"*4EEV${c2} :EEEEEEttttt33@. ${c1} ;3=*^\`\`\`\"*4EEV${c2} :EEEEEEttttt33@.
${c3} ,.=::::!t=., ${c1}\`${c2} @EEEEEEtttz33QF ${c3} ,.=::::!t=., ${c1}\`${c2} @EEEEEEtttz33QF

View file

@ -29,18 +29,20 @@ printinfo () {
info "WM Theme" wmtheme info "WM Theme" wmtheme
info "Theme" theme info "Theme" theme
info "Icons" icons info "Icons" icons
info "Font" font info "Terminal" term
info "Terminal Font" termfont
info "CPU" cpu info "CPU" cpu
info "GPU" gpu info "GPU" gpu
info "Memory" memory info "Memory" memory
# info "Disk" disk # info "Disk" disk
# info "Battery" battery # info "Battery" battery
# info "Font" font
# info "Song" song
# info "Local IP" localip # info "Local IP" localip
# info "Public IP" publicip # info "Public IP" publicip
# info "Users" users # info "Users" users
# info "Birthday" birthday # info "Birthday" birthday
# info "Song" song
info linebreak info linebreak
info cols info cols

View file

@ -56,13 +56,15 @@ printinfo () {
info "WM Theme" wmtheme info "WM Theme" wmtheme
info "Theme" theme info "Theme" theme
info "Icons" icons info "Icons" icons
info "Font" font info "Terminal" term
info "Terminal Font" termfont
info "CPU" cpu info "CPU" cpu
info "GPU" gpu info "GPU" gpu
info "Memory" memory info "Memory" memory
# info "Disk" disk # info "Disk" disk
# info "Battery" battery # info "Battery" battery
# info "Font" font
# info "Song" song # info "Song" song
# info "Local IP" localip # info "Local IP" localip
# info "Public IP" publicip # info "Public IP" publicip
@ -1747,6 +1749,90 @@ getfont () {
# }}} # }}}
# Terminal Emulator {{{
getterm () {
# Check $PPID for terminal emulator.
case "$os" in
"Mac OS X")
# Workaround for OS X systems that
# don't support the block below.
case "$TERM_PROGRAM" in
"iTerm.app") term="iTerm2" ;;
"Terminal.app") term="Apple Terminal" ;;
*) term="${TERM_PROGRAM/\.app}" ;;
esac
return
;;
"Windows")
parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')"
parent=${parent/'PPID'}
name="$(ps -p $parent | awk '{printf $8}')"
name=${name/'COMMAND'}
name=${name/*\/}
;;
*)
parent="$(ps -p ${1:-$PPID} -o ppid=)"
name="$(ps -p $parent -o comm=)"
;;
esac
case "${name// }" in
"${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;;
"login" | "init") term="$(tty)"; term=${term/*\/} ;;
"ruby" | "1" | "systemd" | "sshd" | "python"*) unset term ;;
"gnome-terminal-") term="gnome-terminal" ;;
*) term="$name" ;;
esac
}
# }}}
# Terminal Emulator Font {{{
gettermfont () {
[ -z "$term" ] && getterm
case "$term" in
"urxvt" | "urxvtd" | "xterm")
termfont="$(grep -i "${term/d}\*font" <<< $(xrdb -query))"
termfont=${termfont/*font: }
# Xresources has two different font syntax, this checks which
# one is in use and formats it accordingly.
case "$termfont" in
"xft:"*)
termfont=${termfont/xft:}
termfont=${termfont/:*}
;;
"-"*) termfont="$(awk -F '\\-' '{printf $3}' <<< "$termfont")" ;;
esac
;;
"xfce4-terminal")
termfont="$(awk -F '=' '!/^($|\/\/)/ && /FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")"
;;
"termite")
termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")"
;;
"mintty")
termfont="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")"
;;
"Apple_Terminal")
termfont="$(osascript -e 'tell application "Terminal" to font name of window frontmost')"
;;
esac
}
# }}}
# Disk Usage {{{ # Disk Usage {{{
getdisk () { getdisk () {
@ -3135,7 +3221,7 @@ while [ "$1" ]; do
esac esac
;; ;;
--test) --test)
info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu gpu memory font disk battery song localip publicip users birthday) info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu gpu memory font disk battery song localip publicip users birthday term termfont)
refresh_rate="on" refresh_rate="on"
shell_version="on" shell_version="on"