bin/logo: lsb_release is really expensive, try /etc/issue first,

and fall back to lsb_release if that fails
-Dustin Kirkland <kirkland@ubuntu.com>Fri, 17 Apr 2009 18:11:12 -0500
This commit is contained in:
Dustin Kirkland 2009-04-17 18:34:49 -05:00
commit 28f7467baa
2 changed files with 53 additions and 41 deletions

View file

@ -17,23 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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"
fi
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
@ -59,6 +44,31 @@ elif echo "$distro" | grep -qsi "suse"; then
elif echo "$distro" | grep -qsi "xandros"; then
printf "\005{= Wr} X "
else
printf " ? "
false
fi
exit 0
}
if [ -r "$HOME/.screen-profiles/logo" ]; then
# Allow users to define their own logo
cat "$HOME/.screen-profiles/logo" && exit 0 || true
fi
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
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 " ? "

4
debian/changelog vendored
View file

@ -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 <kirkland@ubuntu.com> Fri, 17 Apr 2009 16:33:53 -0500
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 17 Apr 2009 18:11:12 -0500
screen-profiles (1.46-0ubuntu1) jaunty; urgency=low