Home
Man
Search
Today's Posts
Register

OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple.

A simple plaything for a 19 month old and higher.

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 08-02-2018
A simple plaything for a 19 month old and higher.

This thread today reminded me of it:
Larger window
This is OSX 10.13.6 and greater centric only.
This expands the terminal window on the fly in bash.
You initially need to put the standard terminal window to the top left hand side as far as it goes.
I wrote this for my 19 month old grandson, (17-06-2018), as he loves punching the computer keyboard.
It is a simple keyboard plaything that prints a coloured squared in a random position inside an expanded terminal window. The window size is for a MBP 13 inch device so that is the reason for the odd terminal size.
If the first argument is set to [Yy] then a single alpha-numeric character is spoken so little one can learn said characters as well as printing the random coloured square. If the second argument is set to [Yy] then you can write a sentance of not more than 40 characters to aid in speech learning also with the random coloured square.
If there are no arguments then just the random coloured square is generated per keystroke.
Code:
#!/bin/bash
# Usage: Baby_Play [sppech<Yy>] [word<Yy>]<CR>
# Examples:
# Baby_Play<CR>
# Baby_Play Y y<CR>
#
# For OSX Sierra and above.
# Place default terminal in upper left hand corner.
# Auto expand to maximum size with dock and top bar showing.
printf "%b" "\x1B[8;48;179t"
# Write into terminal header...
printf "%b" "\x1B]0;Baby_Play, press the Delete or Esc, (and Enter), keys to QUIT.\x07"
clear
echo ""
echo "Usage: Baby_Play [speech<Yy>] [word<Yy>]<CR>"
echo ""
echo 'Press the Delete or Esc, (and Enter), keys at any time to QUIT Baby_Play...'
printf "\nPress ENTER/RETURN to continue:- "
read -r -n 1 char
clear
char="Baby_Play_Original_(C)2017,_B.Walker_Licence_CC0."
speech="$1"
word="$2"
colour=$(( ( $RANDOM % 8 ) + 40 ))
x=$(( $RANDOM % 174 ))
y=$(( $RANDOM % 43 ))
escape=$'\x1B'
backspace=$'\x7F'
# Thanks to Corona688 for the stty section below.
inkey() { char="" ; stty -icanon min 0 time 1 ; char=$( dd count=1 2> /dev/null ) ; }
printf "%b" "\x1B["$(( $y + 2 ))";"$(( $x + 3 ))"f\x1B[0;"$colour"m  \x1B[0m"
while true
do
	printf "%b" "\x1B[1;1f\x1B[0m "
	if [ "$word" = "Y" ] || [ "$word" = "y" ]
	then
		printf "Enter word(s), 40 characters maximum:- "
		read -r -n 40 char
	else
		inkey
	fi
	case $char in
		[''${escape}${backspace}])
			break
		;;
		" "|*[0-9a-zA-Z]*)
			colour=$(( ( $RANDOM % 8 ) + 40 ))
			x=$(( $RANDOM % 174 ))
			y=$(( $RANDOM % 43 ))
			if [ "$speech" = "Y" ] || [ "$speech" = "y" ]
			then
				say -v Daniel "$char"
			fi
			printf "%b" "\x1B["$(( $y + 2 ))";"$(( $x + 3 ))"f\x1B[0;"$colour"m  \x1B[0m"
			printf "%b" "\x1B[1;1f\x1B[0m                                                                                "
		;;
	esac
done
# EXIT comes here.
printf "%b" "\x1B[8;24;80t\x1Bc\x1B[2J\x1B[H\x1B[0m"
printf "%b" "\x1B]0;\x07"
clear
echo "Terminal reset back to original state."
exit 0

Have fun little ones.
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove when date is higher radius UNIX for Dummies Questions & Answers 5 11-06-2014 10:31 AM
Need last month files after 10th of every month nani1984 Shell Programming and Scripting 9 07-18-2014 05:56 PM
How to add decimal month to some month in sql, php, perl, bash, sh? bacarrdy Shell Programming and Scripting 14 06-05-2014 08:50 AM
Convert From Month Number to Month Name erin00 Shell Programming and Scripting 1 10-31-2013 07:43 AM
THCOUNT (THCNT) higher than ThreadLimit for httpd process? aarora_98 AIX 3 01-16-2012 11:10 AM
Script to counting a specific word in a logfile on each day of this month, last month etc pnara2 Shell Programming and Scripting 5 08-17-2011 05:00 PM
if test for higher value between 2 decimal numbers emjs Shell Programming and Scripting 5 07-29-2011 10:05 AM
Where to find higher consulting rates? apierce What is on Your Mind? 5 03-01-2011 12:18 PM
Checking for higher usage and mark it superHonda123 Shell Programming and Scripting 11 07-02-2010 12:20 AM
print previous month (current month minus 1) with Solaris date and ksh slashdotweenie UNIX for Dummies Questions & Answers 7 05-14-2010 09:11 AM
grep 2000 and higher tjmannonline UNIX for Dummies Questions & Answers 8 01-09-2010 12:17 AM
Backgrounding process with higher priority keelba UNIX for Advanced & Expert Users 3 01-09-2003 10:52 PM
Fireblade(SUN) need Solaris 8 or Higher ? joerg UNIX for Dummies Questions & Answers 1 08-28-2002 11:10 AM


All times are GMT -4. The time now is 03:23 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password