From 28f7467baa5e9fd8584ec11b0294acd463f6e318 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Fri, 17 Apr 2009 18:34:49 -0500 Subject: [PATCH] bin/logo: lsb_release is really expensive, try /etc/issue first, and fall back to lsb_release if that fails -Dustin Kirkland Fri, 17 Apr 2009 18:11:12 -0500 --- bin/logo | 90 +++++++++++++++++++++++++++--------------------- debian/changelog | 4 ++- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/bin/logo b/bin/logo index 1603bde8..2f48a3d5 100755 --- a/bin/logo +++ b/bin/logo @@ -17,48 +17,58 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +print_logo() { + distro="$1" + if echo "$distro" | grep -qsi "ubuntu"; then + printf "\005{=b kr}\\\\\005{= ky}o\005{=b kY}/" + elif echo "$distro" | grep -qsi "arch"; then + printf "\005{=b wb} A " + elif echo "$distro" | grep -qsi "centos"; then + printf "\005{= gw}*\005{= mw}*\005{= yw}*\005{= bw}*%{=b Wk}" + elif echo "$distro" | grep -qsi "debian"; then + printf "\005{= wr} @ " + elif echo "$distro" | grep -qsi "fedora"; then + printf "\005{=b bw} f " + elif echo "$distro" | grep -qsi "foresight"; then + printf "\005{=b Wg}<@>" + elif echo "$distro" | grep -qsi "gentoo"; then + printf "\005{=b cw} > " + elif echo "$distro" | grep -qsi "mandriva"; then + printf "\005{=b kc} (\005{=b ky}* " + elif echo "$distro" | grep -qsi "redhat"; then + printf "\005{= Rk} RH " + elif echo "$distro" | grep -qsi "slackware"; then + printf "\005{=u Bk},S " + elif echo "$distro" | grep -qsi "suse"; then + printf "\005{= Wg}SuSE" + elif echo "$distro" | grep -qsi "xandros"; then + printf "\005{= Wr} X " + else + false + fi +} + if [ -r "$HOME/.screen-profiles/logo" ]; then # Allow users to define their own logo - cat "$HOME/.screen-profiles/logo" -elif [ -r "$HOME/.screen-profiles/distro" ]; then - # Allow manual override of distro - distro=`cat "$HOME/.screen-profiles/distro"` -elif which lsb_release >/dev/null; then - # If lsb_release is available, use it - distro=`lsb_release -s -a 2>/dev/null` -elif [ -r "/etc/issue" ]; then - # Otherwise, grab part of /etc/issue - distro=`cat /etc/issue` -else - # No idea! - distro="Unknown" + cat "$HOME/.screen-profiles/logo" && exit 0 || true fi -if echo "$distro" | grep -qsi "ubuntu"; then - printf "\005{=b kr}\\\\\005{= ky}o\005{=b kY}/" -elif echo "$distro" | grep -qsi "arch"; then - printf "\005{=b wb} A " -elif echo "$distro" | grep -qsi "centos"; then - printf "\005{= gw}*\005{= mw}*\005{= yw}*\005{= bw}*%{=b Wk}" -elif echo "$distro" | grep -qsi "debian"; then - printf "\005{= wr} @ " -elif echo "$distro" | grep -qsi "fedora"; then - printf "\005{=b bw} f " -elif echo "$distro" | grep -qsi "foresight"; then - printf "\005{=b Wg}<@>" -elif echo "$distro" | grep -qsi "gentoo"; then - printf "\005{=b cw} > " -elif echo "$distro" | grep -qsi "mandriva"; then - printf "\005{=b kc} (\005{=b ky}* " -elif echo "$distro" | grep -qsi "redhat"; then - printf "\005{= Rk} RH " -elif echo "$distro" | grep -qsi "slackware"; then - printf "\005{=u Bk},S " -elif echo "$distro" | grep -qsi "suse"; then - printf "\005{= Wg}SuSE" -elif echo "$distro" | grep -qsi "xandros"; then - printf "\005{= Wr} X " -else - printf " ? " +if [ -r "$HOME/.screen-profiles/distro" ]; then + # Allow manual override of distro + distro=`cat "$HOME/.screen-profiles/distro"` + print_logo "$distro" && exit 0 || true fi -exit 0 + +if [ -r "/etc/issue" ]; then + # Otherwise, check /etc/issue + distro=`cat /etc/issue` + print_logo "$distro" && exit 0 || true +fi + +# This can be a very expensive operation, do it only +# if all other methods fail +distro=`lsb_release -s -a 2>/dev/null` +print_logo "$distro" && exit 0 || true + +# No idea! +printf " ? " diff --git a/debian/changelog b/debian/changelog index 1326e8ac..43a3cb0f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,10 @@ screen-profiles (1.47) unreleased; urgency=low * screen-profiles-status: stop grepping after one match, subtle perf improvement + * bin/logo: lsb_release is really expensive, try /etc/issue first, + and fall back to lsb_release if that fails - -- Dustin Kirkland Fri, 17 Apr 2009 16:33:53 -0500 + -- Dustin Kirkland Fri, 17 Apr 2009 18:11:12 -0500 screen-profiles (1.46-0ubuntu1) jaunty; urgency=low