From 2163f36a18c4302de9df18a339a39297cedcab70 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Tue, 31 Mar 2009 16:48:32 -0500 Subject: [PATCH] bin/logo, profiles/common: dynamically print logo --- bin/logo | 61 +++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 3 ++- profiles/common | 1 + profiles/profile.skel | 2 +- screen-profiles | 1 + 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100755 bin/logo diff --git a/bin/logo b/bin/logo new file mode 100755 index 00000000..ae2b0bd5 --- /dev/null +++ b/bin/logo @@ -0,0 +1,61 @@ +#!/bin/sh -e +# +# logo: determine which logo to use +# Copyright (C) 2008 Canonical Ltd. +# +# Authors: Dustin Kirkland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Default is on +p="logo" +grep -qs "^$p=0$" "$HOME/.screen-profiles/status" && exit 0 + +if [ -r "$HOME/.screen-profiles/distro" ]; then + # Allow manual override + 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 + +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 "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{=b 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" +else + printf " ? " +fi +exit 0 diff --git a/debian/changelog b/debian/changelog index 4263eaa4..2159310e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ screen-profiles (1.42) unreleased; urgency=low * po/*: screen-profiles-export translation template * profiles/common: added 'altscreen on', which cleans the screen for programs that support this, such as vi and emacs, LP: #349677 + * bin/logo, profiles/common: dynamically print logo [ Adi Roiban ] * debian/install, debian/rules, po/POTFILES.python, po/POTFILES.sh, @@ -16,7 +17,7 @@ screen-profiles (1.42) unreleased; urgency=low in the screen-profiles build and install - -- Dustin Kirkland Tue, 31 Mar 2009 15:54:30 -0500 + -- Dustin Kirkland Tue, 31 Mar 2009 16:40:00 -0500 screen-profiles (1.41-0ubuntu1) jaunty; urgency=low diff --git a/profiles/common b/profiles/common index 5d6ce58d..41593e66 100644 --- a/profiles/common +++ b/profiles/common @@ -26,6 +26,7 @@ vbell off msgwait 1 # Define status commands +backtick 99 86400 86400 /var/lib/screen-profiles/logo backtick 100 3600 3600 /var/lib/screen-profiles/release backtick 101 10 10 /var/lib/screen-profiles/updates-available backtick 102 2 2 /var/lib/screen-profiles/reboot-required diff --git a/profiles/profile.skel b/profiles/profile.skel index 77349c3f..4d454c47 100644 --- a/profiles/profile.skel +++ b/profiles/profile.skel @@ -26,7 +26,7 @@ source /usr/share/screen-profiles/profiles/common caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%? %= %{=b Wk}%110`%109` %{= kw}%111`" # Status string, last line -hardstatus string '__LOGO__%{=b Wk} %100` %{= Wk}%112` %= %{=b bW}%102`%{= Wk} %{=b rW}%101`%{= Wk} %{= Wg}%108`%{= Wk} %{= Yk}%106`%{= Wk} %{= Wk}%104`%{=b cW}%103`%{= Wk} %{=b gW}%105`%107`%{= Wk} %Y-%m-%d %0c:%s' +hardstatus string '%99`%{=b Wk} %100` %{= Wk}%112` %= %{=b bW}%102`%{= Wk} %{=b rW}%101`%{= Wk} %{= Wg}%108`%{= Wk} %{= Yk}%106`%{= Wk} %{= Wk}%104`%{=b cW}%103`%{= Wk} %{=b gW}%105`%107`%{= Wk} %Y-%m-%d %0c:%s' # NOTE: Older version of screen have an arbitrary limit of only being able # to change colors 16 times in this 'hardstatus string'. diff --git a/screen-profiles b/screen-profiles index 4e27b048..3f3c17f7 100755 --- a/screen-profiles +++ b/screen-profiles @@ -252,6 +252,7 @@ def readstatus(): status["ec2-cost"]=0 status["hostname"]=0 status["load-average"]=1 + status["logo"]=1 status["mem-available"]=1 status["mem-used"]=1 status["menu"]=1