From 6fccc39524e5ad42e7519199dc091b72e6ee6963 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 21 Oct 2017 10:29:37 +0200 Subject: figlet-center rename to "message" and working (bad busybox awk) --- make-boot-image.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/make-boot-image.sh b/make-boot-image.sh index b6f9536..5f79b5b 100755 --- a/make-boot-image.sh +++ b/make-boot-image.sh @@ -255,6 +255,7 @@ then # When using sudo with password auth, ask and cache pass first $ROOTCMD true # The following compound command will suck at asking pass $ROOTCMD dumpkeys | $ROOTCMD loadkeys -b > "$WORKDIR/initrd/etc/keys.bmap" + cp -a /etc/localtime "$WORKDIR/initrd/etc/" fi if [ ! -f "$WORKDIR/initrd/usr/sbin/partclone.restore" ] @@ -580,12 +581,15 @@ alias sfx-success="sound 1 140 $E6 $G6 $E7 $C7 $D7 $G7" alias sfx-failure="sound 3 100 $C5 1 3 $G4 1 3 $E4 3 0 $A4 2 0 $B4 2 0 $A4 2 0 $Ab4 3 0 $Bb4 3 0 $Ab4 3 0 $G4 6 0" alias sfx-starting="sound 1 25 $C5 $G4 $C5 $E5 $G5 $C6 $G5 $Ab4 $C5 $Eb5 $Ab5 $Eb5 $Ab5 $C6 $Eb6 $Ab6 $Eb6 $Bb4 $D5 $F5 $Bb5 $D6 $F6 $Bb6 $F6" EOF -add_initrd_script "/bin/figlet-center" <<"EOF" +add_initrd_script "/bin/message" <<"EOF" # Output some center ASCII-art text, one line per argument printf '\033]2;'"$*"'\033\\' # Term title (tmux) -while [ -n "$1" ] -do - echo $1 | figlet -t -f mono12 | awk "{ for (i=0;i<($(tput cols)-length(\$0))/2;i++) printf \" \"; print }" +CMDFIG="figlet -t -f mono12" +while [ -n "$1" ]; do + termwidth=$(tput cols) + textlen=$(echo $1 | $CMDFIG | head -n1 | wc -c) + offset=$(( (termwidth-textlen)/2 )) + echo $1 | $CMDFIG | awk "{printf \"%${offset}s\"; print}" shift done EOF -- cgit v1.2.3