my dotfiles
1#!/bin/bash
2
3RED='\033[0;31m'
4BRIGHT_RED='\033[1;31m'
5GREEN='\033[0;32m'
6YELLOW='\033[1;33m'
7WHITE='\033[1;37m'
8NC='\033[0m'
9
10clear
11tput civis
12
13show_boot_message() {
14 local status="$1"
15 local color="$2"
16 local message="$3"
17 local time_info="$4"
18
19 printf "[%b%s%b] %s" "$color" "$status" "$NC" "$message"
20 if [ -n "$time_info" ]; then
21 printf " %s" "$time_info"
22 fi
23 printf "\n"
24}
25
26update_time_display() {
27 local minutes=$1
28 local seconds=$2
29 local dot_pattern=$3
30
31 tput cuu1
32 tput el
33
34 printf "[%b%s%b] A start job is running for Wait for Network to be Configured (%dm %ds / no limit)\n" \
35 "$RED" "$dot_pattern" "$NC" "$minutes" "$seconds"
36}
37
38create_dot_pattern() {
39 local pos=$1
40
41 case $pos in
42 0) printf "%b*%b*%b* " "$RED" "$BRIGHT_RED" "$RED" ;;
43 1) printf "%b *%b*%b* " "$RED" "$BRIGHT_RED" "$RED" ;;
44 2) printf "%b *%b*%b*" "$RED" "$BRIGHT_RED" "$RED" ;;
45 3) printf "%b *%b*%b* " "$RED" "$BRIGHT_RED" "$RED" ;;
46 4) printf "%b*%b*%b* " "$RED" "$BRIGHT_RED" "$RED" ;;
47 esac
48}
49
50start_time=0
51counter=$start_time
52dot_position=0
53direction=1
54frame_count=0
55
56while true; do
57 sleep 0.5
58
59 if [ $((frame_count % 2)) -eq 0 ]; then
60 counter=$((counter + 1))
61 fi
62
63 minutes=$((counter / 60))
64 seconds=$((counter % 60))
65
66 current_pattern=$(create_dot_pattern $dot_position)
67 update_time_display $minutes $seconds "$current_pattern"
68
69 dot_position=$((dot_position + direction))
70 if [ $dot_position -eq 2 ]; then
71 direction=-1
72 elif [ $dot_position -eq 0 ]; then
73 direction=1
74 fi
75
76 frame_count=$((frame_count + 1))
77done
78
79tput cnorm
80echo ""
81echo "Simulation interrupted. Press Ctrl+C to exit..."