Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #252 from dylanaraps/term_font
Browse files Browse the repository at this point in the history
Terminal and Terminal Font detection.
  • Loading branch information
dylanaraps committed Jun 3, 2016
2 parents 4a431b4 + c5b88c6 commit e2e0811
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ascii/distro/windows
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ${c1} ,.=:!!t3Z3z.,
:tt:::tt333EE3
${c1} Et:::ztt33EEEL${c2} @Ee., ..,
${c1} ;tt:::tt333EE7${c2} ;EEEEEEttttt33#
${c1} :Et:::zt333EEQ.${c2} \$EEEEEttttt33QL
${c1} :Et:::zt333EEQ.${c2} $EEEEEttttt33QL
${c1} it::::tt333EEF${c2} @EEEEEEttttt33F
${c1} ;3=*^\`\`\`\"*4EEV${c2} :EEEEEEttttt33@.
${c3} ,.=::::!t=., ${c1}\`${c2} @EEEEEEtttz33QF
Expand Down
6 changes: 4 additions & 2 deletions config/config
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ printinfo () {
info "WM Theme" wmtheme
info "Theme" theme
info "Icons" icons
info "Font" font
info "Terminal" term
info "Terminal Font" termfont
info "CPU" cpu
info "GPU" gpu
info "Memory" memory

# info "Disk" disk
# info "Battery" battery
# info "Font" font
# info "Song" song
# info "Local IP" localip
# info "Public IP" publicip
# info "Users" users
# info "Birthday" birthday
# info "Song" song

info linebreak
info cols
Expand Down
90 changes: 88 additions & 2 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ printinfo () {
info "WM Theme" wmtheme
info "Theme" theme
info "Icons" icons
info "Font" font
info "Terminal" term
info "Terminal Font" termfont
info "CPU" cpu
info "GPU" gpu
info "Memory" memory

# info "Disk" disk
# info "Battery" battery
# info "Font" font
# info "Song" song
# info "Local IP" localip
# info "Public IP" publicip
Expand Down Expand Up @@ -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 {{{

getdisk () {
Expand Down Expand Up @@ -3135,7 +3221,7 @@ while [ "$1" ]; do
esac
;;
--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"
shell_version="on"
Expand Down

0 comments on commit e2e0811

Please sign in to comment.