#!/bin/bashrows=$(tput lines)cols=$(tput cols)colors=(red green blue purple cyan yellow brown)lock_file=lock_file_base=/tmp/$(basename $0 .sh)multiple=0if [[ "$1" ]]; thennsingle=$1shiftelsensingle=10fiif [[ "$1" ]]; thennmultiple=$1shiftif [[ $nmultiple -gt 8 ]]; then nmultiple=8; fielsenmultiple=6fifunction colorstr(){local row=$1local col=$2local color=$3local vcase "$color" inred) v=31;;green) v=34;;blue) v=32;;purple) v=35;;cyan) v=36;;yellow) v=33;;brown) v=33;;white) v=37;;*) v=;;esacshift 3if [[ $multiple -ne 0 ]]; thentouch $lock_filewhile [[ $(ls $lock_file_base.* 2>/dev/null | head -n 1) != $lock_file ]]dosleep 0.05donefitput cup $row $colecho -n -e "\e["$v"m"set -fecho -n $*set +fif [[ $multiple -ne 0 ]]; thenrm -f $lock_filefi}function center_colorstr(){local row=$1local color=$2shift 2local s="$*"local slen=${#s}colorstr $row $(((cols / 2) - (slen / 2))) $color "$s"}function fireworks(){local row=$((rows - 1))local col=$(((RANDOM % (cols / 2)) + (cols / 4)))local height=$((RANDOM % rows - 2))local slantlocal hlocal color1=${colors[$((RANDOM % ${#colors[*]}))]}local color2=${colors[$((RANDOM % ${#colors[*]}))]}local color3=${colors[$((RANDOM % ${#colors[*]}))]}while [[ $color1 == $color2 || $color1 == $color3 || $color2 == $color3 ]]docolor2=${colors[$((RANDOM % ${#colors[*]}))]}color3=${colors[$((RANDOM % ${#colors[*]}))]}donecase $((RANDOM % 4)) in0) slant=-2;;1) slant=-1;;2) slant=1;;3) slant=2;;esacif [[ $height -gt 5 ]]; thenh=$heightwhile [[ $h -gt 0 ]]docolorstr $row $col $color1 '.'let row--if [[ $((col + slant)) -ge $((cols - 3)) || $((col + slant)) -le 2 ]]; then break; filet col+=slantlet h--sleep 0.1doneif [[ $((col + slant)) -lt $((cols - 3)) && $((col + slant)) -gt 2 ]]; thenh=$((height / 5))while [[ $h -gt 0 ]]docolorstr $row $col $color2 '.'let row++if [[ $((col + slant)) -ge $((cols - 3)) || $((col + slant)) -le 2 ]]; then break; filet col+=slantlet h--sleep 0.1doneficolorstr $((row)) $((col - 1)) $color3 '***'colorstr $((row - 1)) $((col)) $color3 '*'colorstr $((row + 1)) $((col)) $color3 '*'fi}for i in $(seq 1 $nsingle)doclearfireworkssleep 1doneclearpids=for i in $(seq 1 $nmultiple)dolet multiple++lock_file=$lock_file_base.$ifireworks &pids="$pids $!"donetrap "kill -9 $pids 2>/dev/null" EXITwait $pidssleep 3clearcenter_colorstr $((rows / 2 - 1)) red "Szczęsliwego nowego roku!"center_colorstr $((rows / 2 + 1)) red "Happy New Year"center_colorstr $((rows / 2 + 3)) red "Your Friends at Linux "echosleep 5clear# vim: tabstop=4: shiftwidth=4: noexpandtab:# kate: tab-width 4; indent-width 4; replace-tabs false;
31 gru 2015
Happy New Year
Subskrybuj:
Komentarze do posta (Atom)
Brak komentarzy:
Prześlij komentarz