How to use script files to avoid attending parties

Recently my wife and our daughter-in-law have decided to spend their entire weekends attending birthday parties for every child below the age of twelve, here in the town where we live. That wouldn't be so bad, but they expect my son and I to go along with them, and they expect us to sit on hard plastic chairs and to eat cake with two and a half inches of frosting on it, as a bunch of kids keep bumping into our elbows. However, this past weekend I was able to avoid having to go to a birthday party for one of my granddaughter's school friends, because I had to spend the entire morning using rsync to restore my installation of FreeBSD. My wife came into our computer room to tell me to get ready, but when I showed her all of the information scrolling on my screen, she agreed that I should probably stay home, because it looked very serious.

That got me thinking....

What if I pipe the output of the tree command into a text file, and then I use script to slowly scroll that text file across my screen, so that it appears that computer is doing something important? Hmm... So, I created the below script file, which will display the output of the text file I created using the tree command, and just to keep it interesting, every once in a while the script will change the color of the text appearing in the terminal window.

Code:
#!/bin/sh

# Check if a file is provided
if [ -z "$1" ]; then
    echo "Usage: $0 <filename>"
    exit 1
fi

FILE="$1"
DELAY=0.09  # Delay in seconds between each line

# Ensure the file exists
if [ ! -f "$FILE" ]; then
    echo "Error: File '$FILE' not found."
    exit 1
fi
# Define colors using ANSI escape codes
# 31=Red, 32=Green, 33=Yellow, 34=Blue, 35=Magenta, 36=Cyan, 37=White
# ANSI Color and Reset codes
colors="\033[37m \033[97m \033[33m \033[93m \033[32m \033[92m"
reset="\033[0m"

# Convert colors string to positional parameters ($1, $2, etc.)
set -- $colors

# Track the initial time in epoch seconds
last_switch=$(date +%s)

# Infinite loop
while true; do
    # Read the file line by line
    while IFS= read -r line; do
        # Get the current time
        current_time=$(date +%s)
      
        # Calculate elapsed time
        elapsed=$((current_time - last_switch))
      
        # Check if 60 seconds have passed
        if [ "$elapsed" -ge 60 ]; then
            # Shift to the next color
            shift
          
            # If we run out of colors, loop back to the first one
            if [ $# -eq 0 ]; then
                set -- $colors
            fi
          
            # Reset the timestamp anchor
            last_switch=$current_time
        fi

        # Print the line with the active color and reset it at the end
        active_color="$1"
        printf "%b%s%b\n" "$active_color" "$line" "$reset"
      
        sleep $DELAY
    done < "$FILE"
done

The text file I created is about 25MB in size, so I only posted a small sample of it below in order to get an idea of what the script will display.

Code:
│ 
├── zstdcat
│   ├── zstdegrep
│   ├── zstdfgrep
│   ├── zstdgrep
│   ├── zstdless
│   ├── zstdmt
│   ├── zstream
│   ├── zstreamdump -> zstream
│   └── ztest
├── include
│   ├── Block.h
│   ├── Block_private.h
│   ├── FlexLexer.h
│   ├── __libunwind_config.h
│   ├── _ctype.h
│   ├── _libsys.h
│   ├── _semaphore.h -> sys/_semaphore.h
│   ├── a.out.h
│   ├── aio.h -> sys/aio.h
│   ├── alias.h
│   ├── ar.h
│   ├── archive.h
│   ├── archive_entry.h
│   ├── arpa
│   │   ├── ftp.h
│   │   ├── inet.h
│   │   ├── nameser.h
│   │   ├── nameser_compat.h
│   │   ├── telnet.h
│   │   └── tftp.h
│   ├── assert.h
│   ├── atf-c
│   │   ├── build.h
│   │   ├── check.h
│   │   ├── defs.h
│   │   ├── error.h
│   │   ├── error_fwd.h
│   │   ├── macros.h
│   │   ├── tc.h
│   │   ├── tp.h
│   │   └── utils.h
│   ├── atf-c++
│   │   ├── build.hpp
│   │   ├── check.hpp
│   │   ├── macros.hpp
│   │   ├── tests.hpp
│   │   └── utils.hpp
│   ├── atf-c++.hpp
│   ├── atf-c.h
│   ├── be.h
│   ├── bitstring.h
│   ├── blacklist.h
│   ├── blocklist.h
│   ├── bluetooth.h
│   ├── bsdxml.h
│   ├── bsdxml_external.h
│   ├── bsm
│   │   ├── audit.h
│   │   ├── audit_domain.h
│   │   ├── audit_errno.h
│   │   ├── audit_fcntl.h
│   │   ├── audit_internal.h
│   │   ├── audit_kevents.h
│   │   ├── audit_record.h
│   │   ├── audit_socket_type.h
│   │   ├── audit_uevents.h
│   │   └── libbsm.h
│   ├── bsnmp
│   │   ├── asn1.h
│   │   ├── bridge_snmp.h
│   │   ├── snmp.h
│   │   ├── snmp_mibII.h
│   │   ├── snmp_netgraph.h
│   │   ├── snmpagent.h
│   │   ├── snmpclient.h
│   │   └── snmpmod.h
│   ├── byteswap.h
│   ├── bzlib.h
│   ├── c++
│   │   └── v1
│   │       ├── __algorithm
│   │       │   ├── adjacent_find.h
│   │       │   ├── all_of.h
│   │       │   ├── any_of.h
│   │       │   ├── binary_search.h
│   │       │   ├── clamp.h
│   │       │   ├── comp.h
│   │       │   ├── comp_ref_type.h
│   │       │   ├── copy.h
│   │       │   ├── copy_backward.h
│   │       │   ├── copy_if.h
│   │       │   ├── copy_move_common.h
│   │       │   ├── copy_n.h
│   │       │   ├── count.h
│   │       │   ├── count_if.h
│   │       │   ├── equal.h
│   │       │   ├── equal_range.h
│   │       │   ├── fill.h
│   │       │   ├── fill_n.h
│   │       │   ├── find.h
│   │       │   ├── find_end.h
│   │       │   ├── find_first_of.h
│   │       │   ├── find_if.h
│   │       │   ├── find_if_not.h
│   │       │   ├── find_segment_if.h
│   │       │   ├── fold.h
│   │       │   ├── for_each.h
│   │       │   ├── for_each_n.h
│   │       │   ├── for_each_segment.h
│   │       │   ├── generate.h
│   │       │   ├── generate_n.h
│   │       │   ├── half_positive.h
│   │       │   ├── in_found_result.h
│   │       │   ├── in_fun_result.h
│   │       │   ├── in_in_out_result.h
│   │       │   ├── in_in_result.h
│   │       │   ├── in_out_out_result.h
│   │       │   ├── in_out_result.h
│   │       │   ├── includes.h
│   │       │   ├── inplace_merge.h
│   │       │   ├── is_heap.h
│   │       │   ├── is_heap_until.h
│   │       │   ├── is_partitioned.h
│   │       │   ├── is_permutation.h
│   │       │   ├── is_sorted.h
│   │       │   ├── is_sorted_until.h
│   │       │   ├── iter_swap.h
│   │       │   ├── iterator_operations.h
│   │       │   ├── lexicographical_compare.h
│   │       │   ├── lexicographical_compare_three_way.h
│   │       │   ├── lower_bound.h
│   │       │   ├── make_heap.h
│   │       │   ├── make_projected.h
│   │       │   ├── max.h
│   │       │   ├── max_element.h
│   │       │   ├── merge.h
│   │       │   ├── min.h
│   │       │   ├── min_element.h
│   │       │   ├── min_max_result.h
│   │       │   ├── minmax.h
│   │       │   ├── minmax_element.h
│   │       │   ├── mismatch.h
│   │       │   ├── move.h
│   │       │   ├── move_backward.h
│   │       │   ├── next_permutation.h
│   │       │   ├── none_of.h
│   │       │   ├── nth_element.h
│   │       │   ├── partial_sort.h
│   │       │   ├── partial_sort_copy.h
│   │       │   ├── partition.h
│   │       │   ├── partition_copy.h
│   │       │   ├── partition_point.h
│   │       │   ├── pop_heap.h
│   │       │   ├── prev_permutation.h
│   │       │   ├── pstl.h
│   │       │   ├── push_heap.h
│   │       │   ├── ranges_adjacent_find.h
│   │       │   ├── ranges_all_of.h
│   │       │   ├── ranges_any_of.h
│   │       │   ├── ranges_binary_search.h
│   │       │   ├── ranges_clamp.h
│   │       │   ├── ranges_contains.h
│   │       │   ├── ranges_contains_subrange.h
│   │       │   ├── ranges_copy.h
│   │       │   ├── ranges_copy_backward.h
│   │       │   ├── ranges_copy_if.h
│   │       │   ├── ranges_copy_n.h
│   │       │   ├── ranges_count.h
│   │       │   ├── ranges_count_if.h
│   │       │   ├── ranges_ends_with.h
│   │       │   ├── ranges_equal.h
│   │       │   ├── ranges_equal_range.h
│   │       │   ├── ranges_fill.h
│   │       │   ├── ranges_fill_n.h
│   │       │   ├── ranges_find.h
│   │       │   ├── ranges_find_end.h
│   │       │   ├── ranges_find_first_of.h
│   │       │   ├── ranges_find_if.h
│   │       │   ├── ranges_find_if_not.h
│   │       │   ├── ranges_find_last.h
│   │       │   ├── ranges_for_each.h
│   │       │   ├── ranges_for_each_n.h
│   │       │   ├── ranges_generate.h

In my machine it takes approximately forty minutes for the entire text file to scroll by, but I imagine that the above would probably scroll by in a few seconds. Also, in my case I enter the name of the batch file and the text file at the same time, rather than have the text file referenced within the script, that way I can have the same script file display different text files, to make it appear that I'm busy with different types of tasks. So you would have to enter something similar to the below.

Code:
./too_busy.sh tree.txt
/CODE]

I don't know how long this will take.  Probably several hours at the least.  After that, pizza and TV time as my wife and our daughter-in-law spend the entire weekend driving all over town together.
 
This of course is one way to do it.
And this one also could be answered with an according xkcd
compiling.png

Just start to compile some large ports. Looks also very busy. 😁
 
Wasn't there a 4 panel, maybe User Friendly, about that? If you're a developer, We're compiling, a sysadmin, we're rebooting, and a couple of others. Ah, can't find it now.
 
Back
Top